View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] beginner1.mat@hotmail.com is offline
external usenet poster
 
Posts: 10
Default Macro to select files and then run different macro on selectedfile

On Jan 30, 4:20*pm, "Conan Kelly"
wrote:
beginner1,

You could try adding this to your "strips data and makes graphs" macro near
the top so this stuff happens before any of the other lines of code get
executed:

dim pstrFilePath as string
pstrFilePath = Application.GetOpenFilename
Application.Workbooks.Open pstFilePath

Now everytime that macro is run, it will prompt you for a file to open, open
that file, and continue on with the code.

If you want to be able to run this macro without being prompted, then put
those 3 lines of code in a separate sub procedure/routine and then call your
other macro as the last line of code in this separate sub.

HTH,

Conan

wrote in message

...



I am familiar with using the record macro function in excel, but I
would like to have excel prompt me as to what file I would like to
select to run a different macro (a macro that strips data and makes
graphs). *Ideally, I would like excel to prompt me to select a folder
(which has all raw excel files) and then run the macro (to make
graphs) on all the .xls files in the folder. *Is this possible?- Hide quoted text -


- Show quoted text -


Thanks for the code. I tried inserting it to the beginning of my
other macro, but got an error on this line:

Application.Workbooks.Open pstFilePath

run-time error '1004':
"could not be found. Check the spelling of the file name, and verify
that the file location is correct.
If you are trying to open the file from your list of most recently
used files, make sure that the file has not been renamed, moved, or
deleted.

Am I missing something?