Talk:Visual Basic for Applications

This is an old revision of this page, as edited by 198.103.195.30 (talk) at 11:47, 6 July 2009 (→‎VSTA Section). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.


Latest comment: 15 years ago by 198.103.195.30 in topic VSTA Section
WikiProject iconComputing: Software Unassessed
WikiProject iconThis article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
???This article has not yet received a rating on Wikipedia's content assessment scale.
???This article has not yet received a rating on the project's importance scale.
Taskforce icon
This article is supported by WikiProject Software.

Please add

1. Discussion of how VBA, WSH, VB script all are similar and may share technology 2. Links to MS documentation on VBA (found on the MS Office developer page)

Indeed it would be good to list specific differences for example between VBA and VB. For example, "VBA doesn't support type casting. It isn't a fully object-oriented language. You can neither inherit classes in your own custom class definitions, nor can you get your objects to behave polymorphically (e.g., cast them as an instance of their base class). VB6 doesn't support inheritance/polymorphism either, but VB.NET and C# do." (http://p2p.wrox.com/topic.asp?TOPIC_ID=26628) ~TP —Preceding unsigned comment added by 91.84.98.138 (talk) 08:37, 19 August 2008 (UTC)Reply

"Hundreds of applications"?

Office, Autocad, Intellicad... anything else? Mathcad and Visual Basic Script.

It looks like the reference to "Hundreds of applications" was removed some time ago. Btw - Visual Basic Script is an independent implementation of Visual Basic based syntax. It is not an application of VBA. Ralphy 09:45, 7 February 2006 (UTC)Reply

Examples

User:Snakeyes060280 - why have you added 'DAO' library qualifications to the object names? Ralphy 16:32, 6 February 2006 (UTC)Reply

Where is there a VBA language reference/specificaation?

I've been looking for an online reference to the VBA language, but have not been able to find anything about the language itself (as opposed to APIs for the various MS Office applications for instance).

Does anyone know where there is a VBA language specification? Erland Lewin 13:40, 15 March 2006 (UTC)Reply

Try Here: http://msdn2.microsoft.com/en-us/isv/aa905357.aspx Oorang (talk) 22:45, 13 February 2008 (UTC)Reply

Edit by 84.146.195.216

I started to remove errors in the edit by 84.146.195.216 on 22:09, 19 September 2006 [1] however I find almost everything in that edit is incorrect or misleading. Furthermore there is a much better discussion of the strengths and weakness of the Visual Basic language in the visual basic article. This is why I am rolling back to the edit before 84.146.195.216. There some of the problems with the edit I am removing:

VBA's entities can be roughly divided in to classes: Firstly, there are the usual elements forming a programming language: data types, variables, control- and loop-struktures. This part of VBA is intended not to be application specific and is used to express the program logic. Secondly, there is an API which allows VBA to interact with it's host application. This API is specific to the relative application.

The APIs described in this section are not part of the VBA language or runtime environment. They are OLE Automation APIs which can be called from VBA and other languages with COM support. This also simplification of VBA also ignores that VBA is more than a language, it is also an integrated development environment. All these parts of VBA are discussed in the Description section of the article.

VBA itself is an [[Interpreter (computing)|interpreted] language. Precompilation is only used for syntax-check and to build tables for the variables used. Therefore VBA cannot be used to create standalone executables. Interpretation also causes the high memory requirement and low execution speed compaired with compiled programs.

VBA is an interpreted language and it can't be used to create standalone executables, I am keeping this in the article. However, this section does not say what VBA is being compared to. I some cases VBA may be slower or require more memory than alternatives and in some cases the opposite is the case. Since VBA runs in process with the application it is automating VBA programs often run faster that out of process compiled programs. Many compiled programs also load large libraries used for COM support.

VBA is a descentant of Microsoft's Visual Basic and therefor has it's roots in the Beginner's All-purpose Symbolic Instruction Code. Like BASIC, VBA also targets end users, being unexperienced programmers or complete beginners in the field of programming. It aims to support many of the simple language constructs, that were used in early BASIC Languages. Since BASIC since the early days lacked standardisation, there were lots of different dialects over the time, so VBA usually supports several syntactial constructs for the same programming goal. This can lead to a confusing variety of syntax and logical breaches: Examples:

  • ) The keyword "Let" might be neglected when asigning predefined types. But when asigning user defined types another keyword, "Set", is mandatory.
  • ) Variables are implicitely defined, except a directive, "Option Explicit", is used at the beginning of a script.
  • ) Subroutines are cathegorized in "functions" (returning a value) and sub (not returning a value). Functions must be called using brackets arount their arguments. Eigher their returnvalue as to be assigned to a variable, or the keyword "call" must be used, while subs must not be used in an assignment. When calling subs, the keyword "call" is optional but determines, whether brackets have to be used or not. All of the above syntax variants exist with named or unnamed arguments, additionally all arguments might be optional, taking on a default value proposed by the programmer when no value is assigned in the call.

I am keeping some of this section since it is correct that VBA is a decedent of BASIC and design decisions in the language favor inexperienced programmers. VBA's attempt to hide the difference between value and reference types does lead to confusion and the ability to omit variable deceleration can lead to errors however these are common in many languages. The description of how Let and Set are used is incorrect. Let is used with value types and set with object references, not with predefined types and user defined types. The use of a keyword to specify whether a subroutine returns a value or not may actually lead to less confusion than other approaches such as using a void return type. The discussion about the Call keyword and the use of practices is completely incorrect in VBA 6.

Despite of its close resemplance to many old BASIC dialects, VBA is not compatible to any of them, except Microsoft Visual Basic: Here the source-code of VBA Modules can be directly imported. Compatibility ends with Visual Basic Verison 6, VBA ist not compatible to VB.NET. Although being along with MS-Office a widespread product, VBA is proprietary to Microsoft and forms no Open standard.

This I am keeping except for the removal of the reference to Microsoft Office as VBA's use within those products has no relationship to whether it is an open standard or not.

VBA still supports flow control using the keyword "goto" (often called Spaghetti code in the jargon) but is mostly designed for Procedural programming.

VBA supports procedural and object orientated programming, event driven programming and possible other paradigms. Goto can lead to Spaghetti code but they are not the same thing. I will link to article on VBA where there is a more in depth discussion of the strengths and weakness of the Visual Basic language

VBA can depict classes and thereby supports data encapsulation, but lacks support for the other [[Object-oriented programming|object-orientated] techniques, like class-attributes and inheritance. So most of the [[Design pattern (computer science)|design patterns] of object orientated programming cannot be realized and VBA cannot be called an object orientated language.

VBA supports class-attributes and interface inheritance and can be used to implement many popular design patterns. I don't know if it can implement most design because there is no list of all design patterens.

Interaction with the host application is usually well documented. One of the most important elements is the "application" object, which integrates almost all automatizeable functions. The API is usually specific to an application and incompatible to all others. So VBA-code written for MS-Office API can not be used in [[OpenOffice]} using the StarBasic-API for example, although StarBasic and VBA are very resemblant considering the language. Most software products (Autodesk AutoCAD / Microsoft Office / Adobe Illustrator) provide an API in form of an 'Object Model' to the Visual Basic Environment allowing the user to create anything from small macros that perform repetitive tasks to extensive programs that add functionality to the host program.

The article on OLE Automation provides a good discussion on how VBA can interact with the host application's APIs. I wall callout more clearly at the start of the article.

Macros can be attached to a menu, button a keyboard shortcut or an event in the application like the opening of the document. Also user-defined functions for excel-worksheets can be provided.

Security Issues VBA is designed without any security features in the language, like for example the sandbox that java appletts run in. Any function of the application or even of the whole operating system, that is accessible to the user running an document containing VBA-macros can be (ab)used by a VBA-makro. Even persons of low programming skills can thus easily write a so called macro virus causing damage to almost unlimited extent. To ensure basic safety for the system and to protect data from espionage or destruction, several measures are necessary:

  • ) An external Virus-Scanner with macro-blocking function must be used, to close the security holes left open by VBA design.
  • ) Macro-capable Documents from unknown or unreliable sources must not be opened.
  • ) Macro-capable applications must not be run as system administrator.
  • ) The signature features provided with newer VBA-Versions should be used to verify the origin of a macro-containing document.

I am leaving this section in with a cleanup tag since it contains a number of errors and typos.

Patleahy 15:59, 20 September 2006 (UTC)Reply

Second Person Adress

In the section addressing security, this article uses second person address. I know generally, this type of address has no place in formal writing, but I'm unfamiliar with the etiquette of this type of article. Should someone reword the offending passage?--Amanaplanacanalpanama 23:06, 7 November 2006 (UTC)Reply

Yes, you should reword it. --Patleahy 15:47, 9 November 2006 (UTC)Reply

Interpreted vs. Compiled

The article says VBA is a interpreted language. The compiled language article lists VBA and the interpreted language article does not. Which is it?Jcdietz03 15:14, 7 May 2007 (UTC)Reply

It's definitely interpreted. If it's compiled then things like CurrentDB or Selection would never work. What happens when VBA codes are run is that the program will run the code from the top (which happens sometimes when badly written vba codes would work in some situations and not in others depends on what programs are open and which files are open). The biggest giveaway is that you don't need to compile first to run VBA macros. :) Leigao84 16:17, 10 May 2007 (UTC)Reply

It is compiled to a p-code machine. It hasn't been interpreted since Access Basic/Word Basic. It takes a text version in BASIC, and compiles it to a seperate copy, which it runs in the VB Virtual Machine, MSVBVM60.DLL, and before that MSVBVM50.DLL. Corruption of the compiled copy is common problem: google the Access coding news groups. Depending on your environment, you may have Compile On Demand or Compile On Save. CurrentDB is a function that does a lookup, including refreshing a collection. I don't know what Selection does, but I do know that you can do File Open in compiled languages: basic input and output is not a mark of an interpreted language.
VBA, which is/was a microsoft product for compilation into a host product, includes an on-demand compiler option. That may look a lot like an interpreter when called from the VBA immediate window, but it's not the same thing.
Obviously, this article needs a lot of work, but it was a labour of love from some one: I'm not going to trash it today. 150.101.166.15 07:23, 31 August 2007 (UTC)Reply
for what it's worth, the MS article about Access 97 currently used as a reference (December 2007), http://support.microsoft.com/kb/109382, is no longer completely accurate: text is not interpreted as you type. Instead, text is syntax checked by an independent syntax checker in the IDE as you type. The syntax checker shares code with the visual studio code completion feature, not the VBA compiler. 218.214.18.240 (talk) 06:05, 29 December 2007 (UTC)Reply

Advert?

This article was tagged advert today. I must say I don't really agree. Anyone in for some discussion? Classical geographer 22:03, 14 August 2007 (UTC)Reply

Concur. I've removed it until the editor can explain his concerns. Kuru talk 23:25, 14 August 2007 (UTC)Reply

UserForms aren't "part of the language" are they?

Aren't UserForms an OLE/ActiveX object that can be used with VBA?150.101.166.15 (talk) 04:25, 13 December 2007 (UTC)Reply

Fair use rationale for Image:VBA logo.jpg

 

Image:VBA logo.jpg is being used on this article. I notice the image page specifies that the image is being used under fair use but there is no explanation or rationale as to why its use in this Wikipedia article constitutes fair use. In addition to the boilerplate fair use template, you must also write out on the image description page a specific explanation or rationale for why using this image in each article is consistent with fair use.

Please go to the image description page and edit it to include a fair use rationale. Using one of the templates at Wikipedia:Fair use rationale guideline is an easy way to insure that your image is in compliance with Wikipedia policy, but remember that you must complete the template. Do not simply insert a blank template on an image page.

If there is other fair use media, consider checking that you have specified the fair use rationale on the other images used on this page. Note that any fair use images lacking such an explanation can be deleted one week after being tagged, as described on criteria for speedy deletion. If you have any questions please ask them at the Media copyright questions page. Thank you.

BetacommandBot (talk) 06:56, 21 January 2008 (UTC)Reply

Pointers

There is a section here that says "VBA is functionally rich and extremely flexible but it does have some important limitations, including limited support for function pointers which are used as callback functions in the Windows API. It has the ability to use (but not create) (ActiveX/COM) DLLs, and later versions add support for class modules."

VBA has an AddressOf operator which returns a pointer to the function for use with API calls.Oorang (talk) 01:19, 28 January 2008 (UTC)Reply

Additional Note: You can get string, object, and variable pointers via the VarPtr, StrPtr, and ObjPtr functions built into the VBA library.[1]Oorang (talk) 19:29, 12 May 2008 (UTC)Reply

Infobox

Add info box. A second pair of eyes would not be amiss Oorang (talk) 01:46, 28 January 2008 (UTC)Reply

a virtual machine hosted inside the container application

Arguably false, but perhaps just a simplification. It uses the VB6 dll,s if they are in memory, or an equivilant set of runtime dlls if the vb6 dlls are not in memory. That is, the virtual machine is hosted by Windows, and the program always runs the same way a non-native mode vb6 program runs. Id change it if I could think of a way to write it that wasnt even more confusing and misleading, but I cant, because of course vba is hosted inside the container application. —Preceding unsigned comment added by 218.214.18.240 (talk) 07:59, 9 February 2008 (UTC)Reply

Fair use rationale for Image:Vba office 2003.PNG

 

Image:Vba office 2003.PNG is being used on this article. I notice the image page specifies that the image is being used under fair use but there is no explanation or rationale as to why its use in this Wikipedia article constitutes fair use. In addition to the boilerplate fair use template, you must also write out on the image description page a specific explanation or rationale for why using this image in each article is consistent with fair use.

Please go to the image description page and edit it to include a fair use rationale. Using one of the templates at Wikipedia:Fair use rationale guideline is an easy way to insure that your image is in compliance with Wikipedia policy, but remember that you must complete the template. Do not simply insert a blank template on an image page.

If there is other fair use media, consider checking that you have specified the fair use rationale on the other images used on this page. Note that any fair use images lacking such an explanation can be deleted one week after being tagged, as described on criteria for speedy deletion. If you have any questions please ask them at the Media copyright questions page. Thank you.

BetacommandBot (talk) 02:33, 12 February 2008 (UTC)Reply

VBA vs. VB Express 2008

VBA is based on the VB6 engine VB Express 2008 is based on VB.net. They are not synonymous. Undid edit by Benrmac129 —Preceding unsigned comment added by Oorang (talkcontribs) 17:57, 10 September 2008 (UTC)Reply

VBA msdn home page: http://msdn.microsoft.com/en-us/isv/bb190538.aspx embedded VBA replacement product: http://www.winwrap.com/web/basic/default.asp

Jargon-laden/buzzword-speak introduction

This article's introduction suffers from jargon-laden computer-ese vacuous buzzword-speak. Words like flexible, dynamic, are just gimmicks and explain nothing.Dogru144 (talk) 21:55, 9 April 2009 (UTC)Reply


Shekhar —Preceding unsigned comment added by 124.247.241.138 (talk) 11:27, 19 May 2009 (UTC)Reply

VSTA Section

VSTA is actually an expansion of Visual Studio available in the Visual Studio SDK. Not part of VBA. I suggest that it belongs in it's own article, then have a blurb in this article referring to it. Oorang (talk) 14:48, 15 June 2009 (UTC)Reply

Is it just me or is the only thing in that section that makes it hard to read all the "citation needed" markings. I understand it just fine. Yeah, maybe it doesn't have a whole lot to do with VBA, other than basically being a direct successor, but half of what is marked as "weasel words" aren't, and almost all calls for citations really don't need it. 198.103.195.30 (talk) 11:47, 6 July 2009 (UTC)Reply