How to write the excel file by Perl with VBA macro inside - excel

My Perl scripts will write the excel file as the output to the user, and I also need this excel file includes the VBA codes.
That means after the use open the excel file, they can run the VBA macro by click the button.
Can I use Perl to write the excel file with macro inside?
If it is unable to do so, the workaround may be :
1. the Perl only write the excel file without macro.
2. attach the macro to that excel file before send to user

Related

Excel file should access another excel file with macros

I am trying to write a macro in an excel file, that can access another excel file where the "real" code is. So the excel file with the original macro code will be updated from time to time and I want the other excel file to always get access to the updated code while running a macro.
Does anybody know how to write a macro, that can access the vba code of another file?
I am a beginner in vba and don't really know where to start…
Thank you! :)

How to copy an active excel sheet and save it into a new workbook using a vbs script?

I'm trying to copy an excel sheet that includes formulas and paste it into a new excel workbook as values and retaining the format using vbs script.
I'm currently doing it but instead of copying I'm saving it as a CSV.
So it is only saving the first page but it looses the format.
Please help.
Thank you.
I found a way around to fix this, I run a vbs to refresh and save the file. then with a batch file i run another script and open the file to only run a macro inside of it and the macro does the job.

Create a ListBox in Excel using Perl

I have a excel spreadsheet that I've created with Perl (Excel::Writer::XLSX) and I'm needing to add a ListBox, but I'm not sure how to do that.
The module does provide a framwork to use vba
from the doc
"An example of adding macros to an Excel::Writer::XLSX file using a VBA project file extracted from an existing Excel xlsm file.
The extract_vba utility supplied with Excel::Writer::XLSX can be used to extract the vbaProject.bin file."
An embedded macro is connected to a form button on the worksheet.
Take a look at marco

Access two excel files using single macro

I have macro, using which i am trying to open a excel file then make some validation in the file that is opened. And Open another excel file and put the validation results(of excel file 1) in the form of report in the 2nd Excel.
So the task i have to do here is:
Open Excel file 1
Script to validate data in excel file 1.
Open Excel file 2
Enter the results in it.
Here i am able to open two excel files but not able to create pointers to them. Such as
if i use Sheets("Sheet1").Range("A1").value 'this picks data from Excel file 1.
But to access Excel file 2 what do i need to write, is this something like this:
Sheets("!Sheet1").Range("A1").value
Please help me to fix this. Thanks.
Application.Workbooks("create-a-macro").Worksheets(1).Range("A1").Value = "Hello"
Visit http://www.excel-easy.com/vba/workbook-worksheet-object.html

Calling macro in a batch script

Can I run a macro in a batch script?
like
SET HOME_PATH=%loaction%
vba %macro%
Is it possible to call a macro in batch script?
You can open an excel file from a batch script and run a macro whenever the excel file is opened, but whatever you are trying to do will probably be done better if it is not done with a macro

Resources