Results 1 to 3 of 3

Thread: VB code to run macros on Excel files

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    2

    Question 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

  2. #2
    Addicted Member phenom's Avatar
    Join Date
    Apr 2006
    Location
    UAE
    Posts
    233

    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:
    1. Try
    2.       'Your coder here....
    3.  
    4.       Catch ex As Exception
    5.       'Do Nothing... Keep it empty...
    6.   End Try

    Hope this helps...

    Regards,
    =======================================
    If I helped you, Kindly Rate my post. Thanks
    -----------
    PHENOM

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    2

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width