dcsimg
Results 1 to 3 of 3
  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2018
    Posts
    4

    What is correct VB coding syntax for running an Excel Macro?

    Hello All,

    Currently I need to include my visual basic project, within Visual Studio 2017 Community version, a correct VB code syntax for running an existing Excel Macro.

    For example I have an existing Excel macro with the file path and name: "C:\documents\Excel1.xlsm", and where in Sheet1 of this excel a macro is included with the name "Macro1".

    According to this relatively old thread in 2001 ( http://www.vbforums.com/showthread.p...Macro-from-VB6 ), the suggested VB code syntax would be:

    obj_Excel.Application.Run "Excel1.xlsm!Macro1"

    However, the VS 2017 community version does not accept this syntax and mentioned that parantheses () must be applied for this function.

    So, when I applied such required parantheses as follows:

    obj_Excel.Application.Run("Excel1.xlsm!Macro1")

    and compiled+build it for an executable application, the desired automated start/execution of the Excel Macro1 did not work unfortunately.

    Do you have any suggestions or proven examples that can help me out?

    Thanks a lot in advance for your help!

  2. #2
    Frenzied Member
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,076

    Re: What is correct VB coding syntax for running an Excel Macro?


  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2018
    Posts
    4

    Re: What is correct VB coding syntax for running an Excel Macro?

    @jdc2000, these are indeed very useful links, thanks a lot!!

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.