In Macro1, you specify the full pathname:Workbooks.Open Filename:= _
        "D:\Phillipins\Automation\Raw Data\CUSTOMIZED REPORT.xlsx"
in the others, you are not defining the path.In the first you ARE using:ChDir 
"D:\Phillipins\Automation\Raw Data"but don't need it in Macro1
since you're not including the path in macro2 and macro3, they would only work 
if you run macro1 first.
I created (3) similar macros and all worked perfectly:Sub tOpen1()
    Workbooks.Open Filename:="C:\temp\vba\Contract_Distribution.xlsx"
    Workbooks("Contract_Distribution.xlsx").Close
End Sub
Sub tOpen2()
    ChDir "C:\temp\vba"
    Workbooks.Open "Contract_Distribution.xlsx"
    Workbooks("Contract_Distribution.xlsx").Close
End Sub
Sub tOpen3()
    Dim wb1
    ChDir "C:\temp\vba"
    Set wb1 = Workbooks.Open("Contract_Distribution.xlsx")
    wb1.Close
End Sub

 Paul-----------------------------------------
“Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can.” - John Wesley
----------------------------------------- 

    On Thursday, March 31, 2016 1:04 PM, Secret Shot <secrets...@gmail.com> 
wrote:
 
 

 Dear Expert,
I am stuck in one very simple macro, and not able to find what's the problem 
is. 
Please help me with it as my entire work got stuck because of it. 
I have three macros for same task, where first 1 is working perfectly and 
opening the workbook "CUSTOMIZED REPORT.xlsx", But rest 2 are giving me error 
of 
"Run-time error '1004': Sorry, we couldn't find "CUSTOMIZED REPORT.xlsx"
Below are the Macros. . . please help is suggesting why I am not able to use 
workbook.open function. 


Sub Macro1()
    
    ChDir "D:\Phillipins\Automation\Raw Data"
    Workbooks.Open Filename:= _
        "D:\Phillipins\Automation\Raw Data\CUSTOMIZED REPORT.xlsx"
End SubSub Macro2()
Dim Wb1 As Workbook
Dim p As Stringp = Workbooks("Data 
Compiler.xlsm").Worksheets("Macro").Range("I6").Value
' Value in Cell I6 is D:\Phillipins\Automation\Raw DataChDir pWorkbooks.Open 
"CUSTOMIZED REPORT.xlsx"
Set Wb1 = Workbooks("CUSTOMIZED REPORT.xlsx")End Sub
Sub Macro3()
Dim Wb1 As Workbook
Dim p As Stringp = Workbooks("Data 
Compiler.xlsm").Worksheets("Macro").Range("I6").Value
' Value in Cell I6 is D:\Phillipins\Automation\Raw DataChDir pSet Wb1 = 
Workbooks.Open("CUSTOMIZED REPORT.xlsx")End Sub

Please help experts . . . 
-- 
Pankaj Pandey
Bhopal-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel
 
FORUM RULES
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
 
NOTE : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at https://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.


 
  

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at https://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to