Adding VBA script to file created from scratch in a react app #2812
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#2812
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'm trying to achieve same results as this thread but
vbablob = wb.vbaraw;
doesn't seem to be workingI'm manually saving the locally extracted vba.bin in S3 bucket and then trying to fetch it, to attach to the new excel workbook generated using
const workbook = xlsx.utils.book_new();
On downloading the xlsm using writeFile, I'm unable to see the validation/ vba macros on the file
On debugging, I see that the vba.bin is in fact successfully added to the workbook.

My export function flow is same as suggested above with exception of reading file from s3
Any pointers would be helpful! Thanks!
Let's start from a simple macro that shows a message on open.
Attached
HelloWorld.xlsx
is the original file (rename to.xlsm
and open to verify the contents)Attached
vba.zip
is the VBA blob (rename to.bin
).
For NodeJS, save the following to
issue2812.js
and runnode issue2812.js
:Attached
issue2812.xlsx
is the generated file in NodeJS (rename to .xlsm and open).
For the browser, save the following to
issue2812.html
, start a local web server withnpx http-server .
and load the page http://127.0.0.1:8080/issue2812.html :The generated file in the browser is identical to the NodeJS file.
.
If you can run the steps here and it works correctly, it'd be useful to look at the actual data coming from S3. Is that blob the same as the uploaded file?
Thank you for a quick response! Yes, I'm able to run all the steps listed above and they work as expected for your file but for some reason it doesn't work with my xlsm file.
I'm able to fetch your vba.bin, save it to S3 and attach it to the workbook generate in the browser, and see a hello world in the message box when I open it.
I'm attaching the vba script (replace .zip with .bin) and the excels I'm using to better understand what might be going wrong, why the macros fails to work
Does my file use unsupported features?
This is the macro I'm trying to attach to the workbook
And then another one on sheet1 for dropdowns in Excel
It'd be great if we could identify if some functionality is currently unsupported
Thank you for taking the time
Looking at the base file, you are adding worksheet-level macros so the codenames must match up. To discover the codenames:
That will print an array of objects. The
CodeName
property of each object must align with the final result. In this case:So that structure must also be built:
Attached is the generated file. Inspecting the generated file, the macros appear and the code names are lining up with the actual sheets. The developer view also shows the code is the same.
PS: you can also just read the base file (the one with the macros) using the
bookVBA: true
option, edit the data withsheet_add_aoa
orsheet_add_json
, then write with thebookVBA: true
option.Aligning the
codenames
with the workbook structure worked! Thank you so much guys