ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run Time 1004 (https://www.excelbanter.com/excel-programming/429323-run-time-1004-a.html)

Rpettis31

Run Time 1004
 
I have the following code that states that the macro/sub cannot be found yet,
and I am not sure why, the workbook opens and I simply copied the path in my
code and then added the macro call. Not sure why I am getting this error.

Workbooks.Open Filename:= _
"G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory Study9.xls"

Workbooks("Inventory Study9.xls").Activate

Application.Run ("'G:\Purchasing\Robert's Stuff\Inventory
Studies\Inventory Study9.xls'!Inventory")


r

Run Time 1004
 
Application.Run ("Inventory Study9.xls!Inventory")

regards
r

Il mio ultimo lavoro ...
http://excelvba.altervista.org/blog/...ternative.html


"Rpettis31" wrote:

I have the following code that states that the macro/sub cannot be found yet,
and I am not sure why, the workbook opens and I simply copied the path in my
code and then added the macro call. Not sure why I am getting this error.

Workbooks.Open Filename:= _
"G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory Study9.xls"

Workbooks("Inventory Study9.xls").Activate

Application.Run ("'G:\Purchasing\Robert's Stuff\Inventory
Studies\Inventory Study9.xls'!Inventory")


Barb Reinhardt

Run Time 1004
 
I've tweaked it a bit. Let me know if it works

Option Explicit

Sub Test()
Dim myWB As Excel.Workbook
Dim myFilePath As String

myFilePath = "G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory
Study9.xls"

On Error Resume Next
Set myWB = Workbooks.Open(Filename:=myFilePath)
On Error GoTo 0

If myWB Is Nothing Then
MsgBox ("Workbook not opened")
End
End If

Application.Run (myWB.Name & "!Inventory")

End Sub


"Rpettis31" wrote:

I have the following code that states that the macro/sub cannot be found yet,
and I am not sure why, the workbook opens and I simply copied the path in my
code and then added the macro call. Not sure why I am getting this error.

Workbooks.Open Filename:= _
"G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory Study9.xls"

Workbooks("Inventory Study9.xls").Activate

Application.Run ("'G:\Purchasing\Robert's Stuff\Inventory
Studies\Inventory Study9.xls'!Inventory")


Tim Zych

Run Time 1004
 
On the right track...just take out the directory name, but keep the single
quotes.

Application.Run "'Inventory Study9.xls'!Inventory"


--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility

"Rpettis31" wrote in message
...
I have the following code that states that the macro/sub cannot be found
yet,
and I am not sure why, the workbook opens and I simply copied the path in
my
code and then added the macro call. Not sure why I am getting this error.

Workbooks.Open Filename:= _
"G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory Study9.xls"

Workbooks("Inventory Study9.xls").Activate

Application.Run ("'G:\Purchasing\Robert's Stuff\Inventory
Studies\Inventory Study9.xls'!Inventory")





Tim Zych

Run Time 1004
 
On the right track...just take out the directory name, but keep the single
quotes.

Application.Run "'Inventory Study9.xls'!Inventory"


--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility

"Rpettis31" wrote in message
...
I have the following code that states that the macro/sub cannot be found
yet,
and I am not sure why, the workbook opens and I simply copied the path in
my
code and then added the macro call. Not sure why I am getting this error.

Workbooks.Open Filename:= _
"G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory Study9.xls"

Workbooks("Inventory Study9.xls").Activate

Application.Run ("'G:\Purchasing\Robert's Stuff\Inventory
Studies\Inventory Study9.xls'!Inventory")





Tim Zych

Run Time 1004
 
That won't work. You need single quotes around the workbook name due to the
fact that it has a space in it.

This modification will work with any workbook name, no matter whether it has
spaces in it or apostrophes or not. Both are considerations when using Run.

Application.Run ("'" & Replace(myWB.Name,"'","''") & "'!Inventory")


--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility

"Barb Reinhardt" wrote in message
...
I've tweaked it a bit. Let me know if it works

Option Explicit

Sub Test()
Dim myWB As Excel.Workbook
Dim myFilePath As String

myFilePath = "G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory
Study9.xls"

On Error Resume Next
Set myWB = Workbooks.Open(Filename:=myFilePath)
On Error GoTo 0

If myWB Is Nothing Then
MsgBox ("Workbook not opened")
End
End If

Application.Run (myWB.Name & "!Inventory")

End Sub


"Rpettis31" wrote:

I have the following code that states that the macro/sub cannot be found
yet,
and I am not sure why, the workbook opens and I simply copied the path in
my
code and then added the macro call. Not sure why I am getting this
error.

Workbooks.Open Filename:= _
"G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory Study9.xls"

Workbooks("Inventory Study9.xls").Activate

Application.Run ("'G:\Purchasing\Robert's Stuff\Inventory
Studies\Inventory Study9.xls'!Inventory")




Tim Zych

Run Time 1004
 
That won't work. You need single quotes around the workbook name due to the
fact that it has a space in it.

This modification will work with any workbook name, no matter whether it has
spaces in it or apostrophes or not. Both are considerations when using Run.

Application.Run ("'" & Replace(myWB.Name,"'","''") & "'!Inventory")


--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility

"Barb Reinhardt" wrote in message
...
I've tweaked it a bit. Let me know if it works

Option Explicit

Sub Test()
Dim myWB As Excel.Workbook
Dim myFilePath As String

myFilePath = "G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory
Study9.xls"

On Error Resume Next
Set myWB = Workbooks.Open(Filename:=myFilePath)
On Error GoTo 0

If myWB Is Nothing Then
MsgBox ("Workbook not opened")
End
End If

Application.Run (myWB.Name & "!Inventory")

End Sub


"Rpettis31" wrote:

I have the following code that states that the macro/sub cannot be found
yet,
and I am not sure why, the workbook opens and I simply copied the path in
my
code and then added the macro call. Not sure why I am getting this
error.

Workbooks.Open Filename:= _
"G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory Study9.xls"

Workbooks("Inventory Study9.xls").Activate

Application.Run ("'G:\Purchasing\Robert's Stuff\Inventory
Studies\Inventory Study9.xls'!Inventory")




Barb Reinhardt

Run Time 1004
 
Thanks for the catch. I know all too well that anything with a blank needs
single quotes around it.

"Tim Zych" wrote:

That won't work. You need single quotes around the workbook name due to the
fact that it has a space in it.

This modification will work with any workbook name, no matter whether it has
spaces in it or apostrophes or not. Both are considerations when using Run.

Application.Run ("'" & Replace(myWB.Name,"'","''") & "'!Inventory")


--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility

"Barb Reinhardt" wrote in message
...
I've tweaked it a bit. Let me know if it works

Option Explicit

Sub Test()
Dim myWB As Excel.Workbook
Dim myFilePath As String

myFilePath = "G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory
Study9.xls"

On Error Resume Next
Set myWB = Workbooks.Open(Filename:=myFilePath)
On Error GoTo 0

If myWB Is Nothing Then
MsgBox ("Workbook not opened")
End
End If

Application.Run (myWB.Name & "!Inventory")

End Sub


"Rpettis31" wrote:

I have the following code that states that the macro/sub cannot be found
yet,
and I am not sure why, the workbook opens and I simply copied the path in
my
code and then added the macro call. Not sure why I am getting this
error.

Workbooks.Open Filename:= _
"G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory Study9.xls"

Workbooks("Inventory Study9.xls").Activate

Application.Run ("'G:\Purchasing\Robert's Stuff\Inventory
Studies\Inventory Study9.xls'!Inventory")





Barb Reinhardt

Run Time 1004
 
Thanks for the catch. I know all too well that anything with a blank needs
single quotes around it.

"Tim Zych" wrote:

That won't work. You need single quotes around the workbook name due to the
fact that it has a space in it.

This modification will work with any workbook name, no matter whether it has
spaces in it or apostrophes or not. Both are considerations when using Run.

Application.Run ("'" & Replace(myWB.Name,"'","''") & "'!Inventory")


--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility

"Barb Reinhardt" wrote in message
...
I've tweaked it a bit. Let me know if it works

Option Explicit

Sub Test()
Dim myWB As Excel.Workbook
Dim myFilePath As String

myFilePath = "G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory
Study9.xls"

On Error Resume Next
Set myWB = Workbooks.Open(Filename:=myFilePath)
On Error GoTo 0

If myWB Is Nothing Then
MsgBox ("Workbook not opened")
End
End If

Application.Run (myWB.Name & "!Inventory")

End Sub


"Rpettis31" wrote:

I have the following code that states that the macro/sub cannot be found
yet,
and I am not sure why, the workbook opens and I simply copied the path in
my
code and then added the macro call. Not sure why I am getting this
error.

Workbooks.Open Filename:= _
"G:\Purchasing\Robert's Stuff\Inventory Studies\Inventory Study9.xls"

Workbooks("Inventory Study9.xls").Activate

Application.Run ("'G:\Purchasing\Robert's Stuff\Inventory
Studies\Inventory Study9.xls'!Inventory")






All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com