VB code to run macros on Excel files
Hi everyone,
(I am not that good at explaining things but i will try my best)
I have wriiten a vb program , which opens an excel file and runs the macro on it. The name of the file and the macro is passed to it through a command line.
basically this process has to be repeated for many files and macros combination , and a batch file will be wriiten which will execute this code automaticallly,
Now the vb file does following things,
opens excel ,
opens the file
runs the macro
and exits
My problem is that sometimes excel throughs message boxes and waits for user inputs , and since this whole process is a batch , there is no human to click the message box and the whole process is stuck.
Is there a way , by which we can trap the message box thrown by excel , check the message in it and do some action and proceed with the next job,
(I can only imagine that there has to be a back ground process which looks out for message boxes and does some action)
I would look forward to your answers
Many Thanks ,
Gaurav
Re: VB code to run macros on Excel files
hi gauravb_98,
I think that you need to put your code between Try Catch... The try encloses the statements that might throw an exception whereas catch handles an exception if one exists....
VB Code:
Try
'Your coder here....
Catch ex As Exception
'Do Nothing... Keep it empty...
End Try
Hope this helps...
Regards,
Re: VB code to run macros on Excel files
I did that , but the message box is not considered as an exception , it is considered a part of the process and vb just waits for the process to complete