Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default 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")

  #2   Report Post  
Posted to microsoft.public.excel.programming
r r is offline
external usenet poster
 
Posts: 125
Default 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")

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default 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")

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default 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")




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default 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")






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default 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")



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default 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")



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default 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")




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default 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")




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run time 1004 cluckers Excel Discussion (Misc queries) 5 January 22nd 10 09:17 PM
Run Time Error '1004' Caleb Excel Programming 5 October 12th 06 02:52 PM
Run time error 1004! steph00 Excel Discussion (Misc queries) 0 May 4th 06 04:45 PM
Run Time Error 1004 Trisha[_2_] Excel Programming 2 November 5th 03 02:29 AM
Run time error '1004' Ikan[_2_] Excel Programming 0 October 29th 03 09:36 PM


All times are GMT +1. The time now is 02:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"