开发者

Convert VBA in access to C#

开发者 https://www.devze.com 2023-01-27 17:09 出处:网络
I have acces file with for开发者_如何学运维ms that create excel file with multiple spreadsheets and I have a task that converts it to C# application that do the same thing the VBA code do and it has a

I have acces file with for开发者_如何学运维ms that create excel file with multiple spreadsheets and I have a task that converts it to C# application that do the same thing the VBA code do and it has alot of code Can I convert the VBA code to (e.g .dll file) that enable me to use the VBA methods in C# or anyway to use VBA code in C# instead of convert it ?

Thanks,

Mohammed Thabet Zaky

http://thabettech.blogspot.com/


If you want to do it yourself, it is possible to just reference the COM stuff. I did this with another application that utilized VBA (AutoCAD). What we ended up doing was creating a .net class that referenced the COM interop and then copied all of the code into that project. This is how we created the .dll file. Then we slowly refactored the vba code into C#.

The copy and paste isn't completely seemless. You do need to make some adjustments. For example thisworkbook, activesheet, and all of those items that are referenced automatically don't work automatically (because you are not out of Excel's process). But (at least for us) it was better than completely re-creating the logic.

Here is a link to some reference material - http://au.autodesk.com/?nd=e_class&session_id=5084. It references Autocad, but doing it in Excel would be very similar.

Hope this helps.


You may have success with the VB Migration Partner, even though it was designed for Visual Basic applications, not office. At least in terms of syntactic migration from VBA to C# it could help.

0

精彩评论

暂无评论...
验证码 换一张
取 消