Running Excel Macro on CSV

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
AndrewT
Junior Coder
Posts: 38
Joined: Thu Sep 17, 2015 6:06 pm

Running Excel Macro on CSV

Post by AndrewT » Fri Apr 13, 2018 7:45 pm

So I have a MS script that creates a CSV file that it then opens in Excel with the ExecuteFile command. From there I want to run an Excel macro that is stored in the PERSONAL.XLSB project location. I have tried the XLRun command but nothing happens. I use the XLGet command first to get the handle of the CSV file. I have also tried to use the XLGet command to get the handle from the PERSONAL.XLSB file, but nothing.

Code: Select all

ExecuteFile>%Path%\Amazon Margin Report.csv
WaitWindowOpen>Amazon Margin Report.csv - Excel
XLGet>C:\Users\AndrewT\Documents\Amazon Margin Report.csv,cvbook
XLGet>C:\Users\AndrewT\AppData\Roaming\Microsoft\Excel\XLSTART\PERSONAL.XLSB,xlbook
XLRun>cvbook,AmzFormat
Anyone have any ideas?

I know I could convert the VBA in VBScript, but it really isn't worth the effort in this case.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Running Excel Macro on CSV

Post by Marcus Tettmar » Mon Apr 16, 2018 5:27 pm

Your code is trying to run a macro in a CSV file, but CSV files do not have macros. I expect you mean to issue the handle for the xlsb file?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

AndrewT
Junior Coder
Posts: 38
Joined: Thu Sep 17, 2015 6:06 pm

Re: Running Excel Macro on CSV

Post by AndrewT » Mon Apr 16, 2018 6:14 pm

I have tried the handle for both the CSV and the XLSB, but neither work.

If you use the ExecuteFile command instead of the XLOpen command, then the XLSB file is automatically loaded in the background.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts