We have some very old VB6 applications that used automation to create Excel Spreadsheets, Word Documents and Outlook Calendar events. Now we want to upgrade those applications to VB.net and perform the same automation tasks. Our issue is that there appears to be very sparse documentation on how to do this now. There is plenty on creating Add-Ons, or interacting with COM objects, but neither of these suit our purposes. We need to be able to interact with Office 2016 (which is presumably .Net not COM) directly to create our outputs. Any help greatly appreciated.
The Office object model is the same for all kind of applications - COM add-ins or automation applications. Anyway, you may find the following articles helpful:
How to automate Word from Visual Basic .NET to create a new document
How to automate Excel from Visual Basic .NET to fill or to obtain data in a range by using arrays
How to automate Microsoft Excel from Visual Basic .NET
How to automate Outlook by using Visual Basic
Is it benificial to download Visual Studio Community for VBA programming?
Or is it better just to run Visual Basics out of a word document
VBA and VB aren't the same thing.
VBA is Visual Basic for Applications and is derived from VB. VBA is encapsulated within Microsoft Office and is primarily event driven, whereas Visual Basic is a fully fledged OOP language that's used within the Visual Studio IDE.
You can create VSTO add-ins for office using VB within Visual Studio - but unless you have a specific reason to I would stick with using VBA as the language has been developed with Office automation in mind, and so the objects and the built in IDE providing features such as IntelliSense are already configured to help you achieve what you need
Ultimate point here is that there's no point re-inventing the wheel. Stick with VBA.
I need to make a windows app. Should I use VB or VB.net? What is the real difference actually? I downloaded visual studio for vb and right now I have "microsoft visual basic 2010 express". I'm assuming if I want to use VB.net it'll say "microsoft visual basic.net 2010 express". Where do I get that from though?
COM-based VB (i.e., "VB6") is obsolete and no longer sold.
VBA is only part of another app or product (such as Excel, Word, etc.) that hosts it and is not appropiate for a stand-alone app.
VB.Net is current, available for purchase (as part of Visual Studio), and supported.
So use VB.Net.
Visual Basic 2010 Express is the IDE to write VB.NET code. You already have the correct program.
As you're starting now - why not use the newest Visual Studio Express 2012?
I am now engaging in an excel vba project. It's a excel front interface for the workers in a site with an Access database in the company network. I dont like much the VBE in Excel 2007, so im wandering if I can do this with VB.NET, which seems to be a more adorable IDE. And where can I find some resources on this? Or recommanded books? Thanks!
Im using Excel 2007 et VB.NET 2008
You could also try Excel-DNA (free). There are many other products out there too. You can make it work with VB.Net Express also, you just need to add a reference to your excel SDK. Also, Add-in Express looks pretty nice. I've never tried it though (costs money).
I think you are looking for Visual Studio Tools for Office: VSTO.
This allows you to develop using VB.NET (or indeed C#) but with full access to the Office automation facilities.
What is the difference between the two. I always thought VBA is somewhat 'crippled' version of VB, but when a friend asked me the other day I had no idea what the actual differences are.
Also, when you use, for example, Excel, is that VB or VBA ?
For nearly all programming purposes, VBA and VB 6.0 are the same thing.
VBA cannot compile your program into an executable binary. You'll always need the host (a Word file and MS Word, for example) to contain and execute your project. You'll also not be able to create COM DLLs with VBA.
Apart from that, there is a difference in the IDE - the VB 6.0 IDE is more powerful in comparison. On the other hand, you have tight integration of the host application in VBA. Application-global objects (like "ActiveDocument") and events are available without declaration, so application-specific programming is straight-forward.
Still, nothing keeps you from firing up Word, loading the VBA IDE and solving a problem that has no relation to Word whatsoever. I'm not sure if there is anything that VB 6.0 can do (technically), and VBA cannot. I'm looking for a comparison sheet on the MSDN though.
VBA stands for Visual Basic for Applications and so is the small "for applications" scripting brother of VB.
VBA is indeed available in Excel, but also in the other office applications.
With VB, one can create a stand-alone windows application, which is not possible with VBA.
It is possible for developers however to "embed" VBA in their own applications, as a scripting language to automate those applications.
Edit: From the VBA FAQ:
Q. What is Visual Basic for Applications?
A. Microsoft Visual Basic for Applications (VBA) is an embeddable programming environment designed to enable developers to build custom solutions using the full power of Microsoft Visual Basic. Developers using applications that host VBA can automate and extend the application functionality, shortening the development cycle of custom business solutions.
Note that VB.NET is even another language, which only shares syntax with VB.
Here's a more technical and thorough answer to an old question: Visual Basic for Applications (VBA) and Visual Basic (pre-.NET) are not just similar languages, they are the same language. Specifically:
They have the same specification: The implementation-independent description of what the language contains and what it means. You can read it here: [MS-VBAL]: VBA Language Specification
They have the same platform: They both compile to Microsoft P-Code, which is in turn executed by the exact same virtual machine, which is implemented in the dll msvbvm[x.0].dll.
In an old VB reference book I came across last year, the author (Paul Lomax) even asserted that 'VBA' has always been the name of the language itself, whether used in stand-alone applications or in embedded contexts (such as MS Office):
"Before we go any further, let's just clarify on fundamental point. Visual Basic for Applications (VBA) is the language used to program in Visual Basic (VB). VB itself is a development environment; the language element of that environment is VBA."
The minor differences
Hosted vs. stand-alone: In practical, terms, when most people say "VBA" they specifically mean "VBA when used in MS Office", and they say "VB6" to mean "VBA used in the last version of the standalone VBA compiler (i.e. Visual Studio 6)". The IDE and compiler bundled with MS Office is almost identical to Visual Studio 6, with the limitation that it does not allow compilation to stand-alone dll or exe files. This in turns means that classes defined in embedded VBA projects are not accessible from non-embedded COM consumers, because they cannot be registered.
Continued development: Microsoft stopped producing a stand-alone VBA compiler with Visual Studio 6, as they switched to the .NET runtime as the platform of choice. However, the MS Office team continues to maintain VBA, and even released a new version (VBA7) with a new VM (now just called VBA7.dll) starting with MS Office 2010. The only major difference is that VBA7 has both a 32- and 64-bit version and has a few enhancements to handle the differences between the two, specifically with regards to external API invocations.
Do you want compare VBA with VB-Classic (VB6..) or VB.NET?
VBA (Visual Basic for Applications) is a vb-classic-based script language embedded in Microsoft Office applications. I think it's language features are similar to those of VB5 (it just lacks some few builtin functions), but:
You have access to the office document you wrote the VBA-script for and so you can e.g.
Write macros (=automated routines for little recurring tasks in your office-work)
Define new functions for excel-cell-formula
Process office data
Example: Set the value of an excel-cell
ActiveSheet.Cells("A1").Value = "Foo"
VBC and -.NET are no script languages. You use them to write standalone-applications with separate IDE's which you can't do with VBA (VBA-scripts just "exist" in Office)
VBA has nothing to do with VB.NET (they just have a similar syntax).
Actually VBA can be used to compile DLLs.
The Office 2000 and Office XP Developer editions included a VBA editor that could be used for making DLLs for use as COM Addins.
This functionality was removed in later versions (2003 and 2007) with the advent of the VSTO (VS Tools for Office) software, although obviously you could still create COM addins in a similar fashion without the use of VSTO (or VS.Net) by using VB6 IDE.
It's VBA. VBA means Visual Basic for Applications, and it is used for macros on Office documents. It doesn't have access to VB.NET features, so it's more like a modified version of VB6, with add-ons to be able to work on the document (like Worksheet in VBA for Excel).
VB is not a language. VB is a program that hosts VBA, just as Office hosts VBA. VB is a set of App objects, just like Word and Excel have, and a forms package, just like in Office.
So you can only write VBA code in VB.
PS this info is on the INFO tab on the VB question page for VB.
From VBA Info
VBA 6, was shipped in 1998 and includes a myriad of licensed hosts, among them: Office 2000 - 2010, AutoCAD, PI Processbook, and the stand-alone Visual Basic 6.0
VBA stands for Visual Basic For Applications and its a Visual Basic implementation intended to be used in the Office Suite.
The difference between them is that VBA is embedded inside Office documents (its an Office feature). VB is the ide/language for developing applications.
VB (Visual Basic only up to 6.0) is a superset of VBA (Visual Basic for Applications). I know that others have sort of eluded to this but my understanding is that the semantics (i.e. the vocabulary) of VBA is included in VB6 (except for objects specific to Office products), therefore, VBA is a subset of VB6. The syntax (i.e. the order in which the words are written) is exactly the same in VBA as it would be in VB6, but the difference is the objects available to VBA or VB6 are different because they have different purposes. Specifically VBA's purpose is to programatically automate tasks that can be done in MS Office, whereas VB6's purpose is to create standard EXE, ActiveX Controls, ActiveX DLLs and ActiveX EXEs which can either work stand alone or in other programs such as MS Office or Windows.