Click here to Skip to main content
15,903,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello code project world,

i have a code and i was wondering if it is possible to convert it to vba excel macro?

the issue is that i can't use an application .exe and was wondering if i can convert or integrate the code into an excel?!

thank you

What I have tried:

I copied the code into an excel macro module and tried to work on the error lines, however it is not easy and i'm new to coding
Updated 4-Apr-23 13:32pm
Member 15627495 15-Feb-23 15:19pm    
in process call, you can run ".net" with a 'vba macro'.

VBA and .Net are compliant.
Member 15627495 15-Feb-23 15:23pm    
give up with "code converting", make them both 'working for each other'.

You would have to rewrite the code from scratch. There is no conversion tool that will do it for you.

Copying and pasting the VB.NET code into a VBA module will do you no good. The two languages are vastly different from each other making it impossible for a direct line-for-line conversion to work.

You would have to understand the intent of what the VB.NET code is doing and write entirely new code to accomplish the same task.
Share this answer
As Dave says, VB.Net and VBA are very different languages which share some common syntax - the framework behinds them is vastly different, and would not be simple to convert - especially without seeing the original code or having any idea what it does.

The other thing to consider is your "throwaway line":
i can't use an application .exe
We have no idea why, but there are generally two reasons:
1) It's against company / establishment policy to allow unapproved executables.
2) It's an attempt to hide the executable from the user.

The first case means you shouldn't even try: if they catch you - and they will, they have been doing this for longer than you have - you will be subject to disciplinary action. In some cases this will mean they wave goodbye to you immediately ... Companies and institutions do take this kind of thing seriously.

The second case is a bigger problem: jail time, fines, public humiliation - it depends one what the code does or is intended to do. Loads of people take this seriously!

If I was you, I'd think long and hard before moving forward with any such project, even if it seems innocuous to you.
Share this answer
You can use Excel like a COM component from or any other .net language

Microsoft documentation for VB is there

COM Interop - Visual Basic | Microsoft Learn[^]

If it is for job, you should check with your IT department if they allow it.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900