Roy Lasris said:
I am sure this has been asked before, so a reference to a white paper of
something similar is fine.
How can I make a VBA(Word) project into a VB project. Is it as simple as
creating a Word application object in VB and then copying and pasting the VBA
project 'underneath' the object? Or will all the code likely have to be redone.
I know that the above is an oversimplification of the issue, but I just want to
have a bit of an idea of what I am getting into if I decide to buy VB 6 or ..net
and try it.
If you are using VB6, then broadly this is the idea. You'll need to make an
explicit reference to the Word object model by creating an object variable
that links to the Word object model, and you will then have to prefix all
lines of code that use Word objects with the Word object variable .
In addition, you should be aware that VB6 Forms and VBA UserForms, while
looking quite similar, are very different beasts under the hood. If you are
wanting to move a UserForm to a VB form, then some rewriting will be needed.
Much of the event code can be copied and pasted across, but there are some
ways in which the forms behave differently. Testing is the order of the day
here.
With VB.NET, there are additional issues which might make you want to avoid
using it for your application. These include:-
- The syntax is noticeably different. For instance, what VBA calls an
Integer is defined as a Short by VB.NET, and what VBA calls a Long is an
Integer. Copying and pasting code is not going to cut it, though the latest
version of VB.NET does have a "snippet converter" which tries to convert
code from VB6 syntax to the equivalent VBA syntax.
- WinForms which are the forms package in VB.NET are different again from
both VBA UserForms.
- VB.NET is not based on ActiveX (COM) unlike both VB6 and VBA, so you have
to make some special arrangements for compiling VB.NET projects as COM
objects so that a Word VBA macro can actually see the object and use it.
- The runtime for VB.NET is not yet distributed on all PCs - it isn't part
of the standard distribution even for Windows XP. Therefore, for VB.NET
projects to run on other PCs, you will have to ensure that the .NET runtime
is distributed and installed. That is a 20MB installation package,
effectively ruling out distribution by diskette or download over a dialup
connection. For practical purposes you are limited to installation from LAN,
broadband connection or CD.
- VB.NET programs will not run on Windows 95, and in order to develop you
need (if I recall correctly) a minimum of Windows 2000 SP3 or Windows XP.
The great advantage of VB.NET is of course that it is actually on sale! VB6
has been discontinued for some time, and you can only get a copy secondhand.
For more information, do a google search of the Microsoft website for "COM
add-in"