簡體   English   中英

使用 Vb.net 導出 VBA 宏

[英]Export VBA macro using Vb.net

我有以下情況:

一方面,我有我的Vb.net應用程序,我可以從中訪問/運行存儲在 Excel 工作簿 ( *.xlsm ) 中的宏。 感謝Microsoft.Office.Interop.Excel沒什么大不了的。

我可以簡單地通過xl.App.Run(macroname)甚至參數訪問宏。

現在我想查看/解析宏本身的代碼以進一步分析它們 - 有沒有辦法?

如果您可以從 VB.NET 運行 Excel VBA 宏,那么您可以運行此處描述的 Ron de Bruin 代碼:

導入和導出 VBA 代碼

dim CompareRange As Variant, x As Variant, y As Variant ' Set CompareRange equal to the range to which you will ' compare the selection. Set CompareRange = Range("C1:C5") ' NOTE: If the compare range is located on another workbook ' or worksheet, use the following syntax. ' Set CompareRange = Workbooks("Book2"). _ ' Worksheets("Sheet2").Range("C1:C5") ' ' Loop through each cell in the selection and compare it to ' each cell in CompareRange. For Each x In Selection For Each y In CompareRange If x = y Then x.Offset(0, 1) = x Next y Next x

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM