Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


eme

eme

103 posts

Master Geek
+1 received by user: 5


#173528 26-May-2015 17:25
Send private message

I'd like to come to grips with Visual Studio by migrating some of my Excel VB Scripts to it.
Anyone have recommendations to make a start.
I am familiar with the "Hello World" type examples.

Create new topic
Alagalac
4 posts

Wannabe Geek


  #1318326 6-Jun-2015 16:32
Send private message

Hmm.. I built a program which will automatically extra VBA macros from spreadsheets and convert them into VB.net classes. Although since I did this as work it'll be company IP so can't really distribute it.

But it should be pretty straightforward to create an empty new vb.net class in visual studio, and then copy and paste the VBA macro into it. Visual studio will highlight any compilations errors to fix up.



eme

eme

103 posts

Master Geek
+1 received by user: 5


  #1318399 6-Jun-2015 18:34
Send private message

Thanks Alagalact, that should be instructive.
Are you suggesting I copy the whole contents of a module to a VS VB Class?

Alagalac
4 posts

Wannabe Geek


  #1318458 6-Jun-2015 21:52
Send private message

Yeah pretty much. I guess it really depends upon what you're wanting to do.

If you're wanting to manipulate the excel workbook, then you'll want to use the excel interop library.
See this link for a quick example of manipulating a workbook via the interop: http://www.dotnetperls.com/excel-vbnet

If you don't need to directly access the workbook then you won't need to use the interop library. Quite a few of the functions
have changed between vb.net, and VBA used in Excel but microsoft has provided a compatibility library if you don't want to
refactor the code. It's all under the Microsoft.VisualBasic.Compatibility.VB6 namespace, although I believe there a dll you'll need
to add a reference too.



eme

eme

103 posts

Master Geek
+1 received by user: 5


  #1318463 6-Jun-2015 22:12
Send private message

Thanks for the tips, I'll have a go with the compatability name space reference switched on , Hopefuly it's not to far from runable. I have a tricky function that gets a cell from a closed workbook, I'll see how the compatability gets on with that.

Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.