What is the difference between VB and VBA?

I am working on this project (AddIn) for Excel 2007. It uses aspose cells for this purpose, as well as C #. I did not write the code, but I took on the project from someone else. Therefore, I am still studying the excel part, as I only know C #. I noticed that there is some code to create a workbook / worksheet. How do I know if it is written in VB or VBA so that I can study it? File extensions are similar to .cls, .frm, .bas, etc. I am using Visual Studio 2010.

In addition, the workbook / worksheets are password protected after creation. When I tried to change the password using the VB / VBA code (no matter what it is), it creates errors during the build, such as the expected identifier, declaration, expected, etc. But when I turn off the changes, all errors disappeared. The only change I made was to change the line in which the password is stored. (the string "password" was changed to "password1"), and suddenly other lines of code began to receive errors. Errors are the expected identifier, the expected announcement, etc., and it does not 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 to set breakpoints through VS2010, but did not hit them when I started the project. I am sure that worksheets are created using VB / VBA and therefore fall within these codes, but cannot be debugged.

I open AddIn using Visual Studio2010, and how to work with the code, both C # and VB / VBA. I can’t change anything with Alt + F11.

+6
source share
2 answers

.cls, .frm and .bas are VBA files. I suggest you try debugging your code in Excel using VBE (the equivalent of Visual Studio for VBA). It is quite easy to debug in this environment.

The difference between VB (VB.Net) and VBA is quite large. At the same time, VBA is a fairly simple language, so if you manage to understand C #, I'm sure that you can learn VBA with a little reading and experimenting.

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

+2
source

How do you get to the code? If through Excel using VBE, for example, by pressing Alt + F11, then this is VBA. If you open a project, then this is probably VB (VB6). Please note that VB.NET uses the .vb extension. Moreover, since VBA is a subset of VB, then if you export VBA from a VBE project, the exported files will be added to their VC cousin extensions by default.

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

As I said, VBA (6.x) is a subset of VB6. The Excel part is just an object model using VBA. VB.NET is different, and it is not, because the file extensions are incorrect.

So focus on VBA and Excel 2007 object model training

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

Creating VBA macros to manipulate worksheets in Excel 2007 http://msdn.microsoft.com/en-us/library/dd553655(v=office.12).aspx .

This article VBA compatibility 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.

0
source

Source: https://habr.com/ru/post/901355/


All Articles