r/visualbasic • • Jul 02 '15

Making GUI, VBA needs to populate Excel sheet. I did all the work except this part, thought it would be cake. Is it even possible? First time using VBA. [Visual Studio 2012 + Office 2010]

So I'm making this GUI and I was under the impression the VBA could grab data from text boxes and put them in an excel sheet. After a lot of googling I'm getting the impression the VBA might not be able to do it, some show VB.Net can do it, others say I need to use some Microsoft add on / extension thing. Basically, I'm confused on what the real answer is. I did a lot of work already and I saved this for last because I thought it was going to be the easy part. I really don't want to start from scratch . Ideas? I'm using Visual Studio 2012 and Office 2010.

5 Upvotes

4 comments sorted by

3

u/hdsrob Jul 02 '15

I think you are probably confusing the different languages involved, and the different methods available to work with office.

VBA is not used from Visual Studio, but is the scripting language built into Office, and used within Office (via Developer Tools).

VB.NET is the language used within VS, so if you are using VS, and created a new Windows Forms or WPF project, then you are using VB.NET.

You can certainly manipulate Excel from VB.NET:

http://www.visual-basic-tutorials.com/WriteToExcel2007.php

1

u/whyyunozoidberg Jul 02 '15

How can I be sure that I'm not running VB6? Some VB.NET commands didn't work for me. Is it because I don't have the libraries? The commands that related to Excel, like .Workbook.

2

u/hdsrob Jul 02 '15

VB6 is from 1998, and runs in Visual Studio '98. If you are in VS 2012, you are in .NET

Make sure you added the reference to the Excel Library, as in the first few paragraphs in that tutorial. You'll also have to have Excel installed on the machine (and any machine that uses your app).

2

u/whyyunozoidberg Jul 02 '15

THANK YOU. THIS EXPLAINS SO MUCH.

I'll let you know the results.