#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Error 1004

I am not sure where I have gone wrong with codes below. Every time I run it, I get a run time error 1004 ... the macro cannot be found; but the macro file is there!

file_name = Userform1.ListBox1.Value & ".xla"
pgm2run = file_name & "!StartPgm"

Workbooks.Open Filename:=file_name
Application.Run pgm2run

I am using Excel 2002 on Windows XP Professional. PLease help. TIA

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Error 1004

Hi Dave, Thanks for your suggestion.

Anyway I have managed to overcome the run time error. For the benefits of other users, here is how I did it. I changed lne #2 of the code to pgm2run = "Startpgm" from pgm2run=file_name & "!StartPgm"; dropping the file_name. Here is the new code -

file_name = Userform1.ListBox1.Value & ".xla"
pgm2run = "StartPgm"
Workbooks.Open Filename:=file_name
Application.Run pgm2run


"Dave Newing" wrote:

Hi Francis,

I think run time error 1004 is file does not exist.

Check that the file string you are looking for is correct.
One way of doing this is to print the variable 'file_name' to your immediate window by adding:

Debug.Print file_name

After:

file_name = Userform1.ListBox1.Value & ".xla"

Your immediate window can be opened by pressing Ctrl+G.






"Francis Ang" wrote:

I am not sure where I have gone wrong with codes below. Every time I run it, I get a run time error 1004 ... the macro cannot be found; but the macro file is there!

file_name = Userform1.ListBox1.Value & ".xla"
pgm2run = file_name & "!StartPgm"

Workbooks.Open Filename:=file_name
Application.Run pgm2run

I am using Excel 2002 on Windows XP Professional. PLease help. TIA

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
why am i getting an error 1004?? please help SAM SEBAIHI Excel Discussion (Misc queries) 2 February 16th 07 02:21 AM
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
Runtime error '1004' General ODBC error star_lucas New Users to Excel 0 August 29th 05 04:09 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
VBA error - run-time error '1004': Romanian37 Excel Programming 3 May 21st 04 03:25 PM


All times are GMT +1. The time now is 09:34 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"