简体   繁体   中英

what is the difference between VB vs VBA?

I am working on this project (an AddIn) for Excel 2007. It use aspose cells for this purpose as well as C#. I didn't write the code, but took over the project from somebody else. So I am still learning the excel portion as I know only C#. I did notice there is some code for creating workbook/worksheet. How do I know if its written in VB or VBA so that i can learn it?The file extensions are like .cls, .frm, .bas etc. I am using Visual Studio 2010.

Also the workbook/worksheets are password protected after creation.When I tried to change the password through VB/VBA code(whatever it is), it creates errors during build such as identifier expected, declaration expected etc.But when I undid the changes, all the errors disappeared. The only change I made was change the string that stored the password. (string "password" was changed to "password1") and suddenly other lines of code started getting errors.The errors are identifier expected, declaration expected etc. and that doesn't make sense to me. So i had to change the password through C# after it was password protected through VB/VBA. Also, how do I debug VB/VBA code. I tried putting breakpoints through VS2010 , but it's not hitting them when I run the project.I am sure the worksheets are created using VB/VBA and so its getting inside those codes, but cant debug.

I open the AddIn using Visual Studio2010 and that's how work with the code,both C# and VB/VBA.I dont modify anything using Alt+F11.

.cls, .frm, and .bas are VBA files. I suggest you try debugging the code in Excel using the VBE (the Visual Studio equivillent for VBA). It's quite easy to debug in that enviornment.

The difference between VB (VB.Net) and VBA is quite big. That being said, VBA is a rather simple language, so if you have managed to grasp C#, I'm sure you can learn VBA with a little bit of reading and experimentation.

If you have a question about the actual code, I suggest you post it as a seperate question. :)

How do you get to the code? If through Excel by using the VBE, for instance by pressing Alt+F11, then it is VBA. If you open a project, then it is probably VB (VB6). Note that VB.NET use the .vb extension. Moreover, since VBA is a subset of VB then if you export VBA from a VBE project, the exported files default to their VB cousin's file extensions.

We really need to know how you get to the code.

Like I said, VBA (6.x) is a subset of VB6. The Excel part is just an object model that uses VBA. VB.NET is different and is not the case because the file extensions are wrong.

Therefore, concentrate on learning on VBA and Excel 2007 Object Model

MSDN Search for VBA at http://social.msdn.microsoft.com/Search/en-US?query=VBA&ac=8 .

Creating VBA Macros to Manipulate Worksheets in Excel 2007 at http://msdn.microsoft.com/en-us/library/dd553655(v=office.12).aspx .

This article VBA Interoperability with Visual Studio Tools for the Office System (3.0) at http://msdn.microsoft.com/en-us/library/bb931201(v=office.12).aspx should help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM