问题
I want to write certain macro script in a cell as text. Googled, but I found nothing.
回答1:
You could export your module to a file:
ThisWorkbook.VBProject.VBComponents(Module.name).Export ModuleFile
Then read that file in to a variable. Parse it, and do whatever you want with the text at that point. This requires programmatic access to VBA, which as @GSerg points out is a terrible idea. It opens you up to malware VBA code attacks.
来源:https://stackoverflow.com/questions/57526534/is-there-a-way-to-save-macro-script-into-a-variable-as-string-in-visual-basic