Error 1004

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top