Is there a way to save macro script into a variable as string in Visual Basic?

淺唱寂寞╮ 提交于 2021-01-29 13:05:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!