+ Reply to Thread
Results 1 to 9 of 9

Calling a VBA macro from Perl script

  1. #1
    Registered User
    Join Date
    07-03-2013
    Location
    Brussels
    MS-Off Ver
    Excel 2007
    Posts
    5

    Calling a VBA macro from Perl script

    Hi all,

    I have an excel sheet (extension .xlsm) with mutliple sheets and a lot of functions/formula's to be calculated using the inputparameters in the first sheet. That's why I'm using a Perl script to update the parameters in the first sheet and afterwards (re)calculate all values in all other sheets.

    To (re)calculate the Excel sheet, I created the following macro:

    Please Login or Register  to view this content.
    If I execute this macro manually in the excel sheet, the recalculation runs successfully.

    However, I want to call this macro from my Perl script which has the following code:

    Please Login or Register  to view this content.
    The macro is excuted successfully, I see that the "BEGIN" and "END" is printed correctly in the right cells. These prints are in the macro, before and after the calculation function. However, the (re)calcalation doesn't seem to work as my functions/fomula's are not recalculated.

    I hope somebody can help me?

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Calling a VBA macro from Perl script

    Why don''t you use the Perl script to do what the macro does?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    07-03-2013
    Location
    Brussels
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Calling a VBA macro from Perl script

    Quote Originally Posted by Norie View Post
    Why don''t you use the Perl script to do what the macro does?
    Problem is I don't know how to do this in Perl...

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Calling a VBA macro from Perl script

    Why are you using Perl?

    Couldn't you do everything in VBA?

  5. #5
    Registered User
    Join Date
    07-03-2013
    Location
    Brussels
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Calling a VBA macro from Perl script

    Maybe .. you mean with a Visual Basic script?

    Can you please help me how to ..
    (1) open excel file in VB script?
    (2) do a (re)calculate off the full excel workbook in the script?

    thanks in advance!
    Last edited by nickmas; 07-03-2013 at 10:45 AM.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Calling a VBA macro from Perl script

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Calling a VBA macro from Perl script

    No I mean with VBA.

  8. #8
    Registered User
    Join Date
    07-03-2013
    Location
    Brussels
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Calling a VBA macro from Perl script

    Please Login or Register  to view this content.
    I'm using the code above right now and this works except .. the calculate (which is still not done )
    Last edited by nickmas; 07-04-2013 at 04:33 AM.

  9. #9
    Registered User
    Join Date
    07-03-2013
    Location
    Brussels
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Calling a VBA macro from Perl script

    I'm currently using the code below:

    test.vbs
    Please Login or Register  to view this content.
    However, the Prophet functions (add-ins) are not loaded correctly and that's why all formulas (which make use of this add-in) are not executed and the "CalculateFull" doesn't do anything. Please can anybody help me on how to open the excel with all add-ins?

    If I open the excel manually (with the same user as the one which I use to execute the VBS script), it's no problem and the Prophet add-ins are loaded correctly. I also see there's an extra "Prophet" tab in Excel, like "Home", "Insert", "Page Layout", "Formulas", "Data",...
    Last edited by nickmas; 07-09-2013 at 10:33 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1