migrate word vb6 macros to word 2007 and windows 7

A

Alfred

Over the years I wrote dozens of macros in VB6, while using Word 2003
and Windows XP.
My question is: what will happen with all these macros if I migrate to
Word 2007? And what happens if I start using Windows 7 as well?
Thanks to anyone who can help me out.
Alfred
 
D

dedawson

One problem I ran into was a change in the means of activating an open
Word doc.
Had to write a bit of code to determine if running under 2003 or 2007.

Sub Get_Word_Version()
'
' Called by Word version-dependant VBA
' Returns currently running Word version in global variable sVersion
'
On Error GoTo MyError
Dim oApp As Object
'Dim sVersion As String
Set oApp = GetObject(, "Word.Application")
If TypeName(oApp) = "Nothing" Then
Set oApp = CreateObject("Word.Application")
End If
Select Case Left$(oApp.Version, InStr(1, oApp.Version, ".") + 1)
Case "8.0"
sVersion = "97"
Case "9.0"
sVersion = "2000"
Case "10.0"
sVersion = "2002"
Case "11.0"
sVersion = "2003"
Case "12.0"
sVersion = "2007"
Case "14.0"
sVersion = "2010"
Case Else
sVersion = "Too Old!"
End Select
' MsgBox "Word version: " & sVersion
Exit Sub
MyError:
If Err.Number = 429 Then
Resume Next
Else
MsgBox Err.Number & " - " & Err.Description
End If
End Sub ' Sub Get_Word_Version

Then used that result to decide how to activate within other VBA.

If sVersion = 2007 Then ' 2007 uses 'documents'
Documents(cTargetDoc).Activate
Else ' 2003 uses windows
Windows(cTargetDoc).Activate
End If

..
There may have been other ways around this, but this approach worked
well.
 
A

Alfred

Thank you, but this is not what I meant. I am not a programmer at all,
but by lots of efforts I managed to create some dozens of VB macros in
Word 2003, which I want to keep using.
I read that, starting in Word 2007, VB6 is not functioning anymore.
My question is: when I migrate from Word 2003 to Word 2007 would I
have to rewrite my VB6 macros in another language?
My second question is: can I use Word 2003, including my VB6 macros,
in Windows 7?
 
J

Jay Freedman

I read that, starting in Word 2007, VB6 is not functioning anymore.

Wherever you read that, it's wrong. Word 2003 and Word 2006 both run
VBA6 (not VB6; "Visual Basic for Applications" and "Visual Basic" are different
but related languages). Word 2010 has VBA7, which will run everything
written in VBA6 and more.
My question is: when I migrate from Word 2003 to Word 2007 would I
have to rewrite my VB6 macros in another language?

No, you wouldn't have to rewrite them in another language (and I can't imagine
what language that would be -- Urdu, maybe?).

But there are some things that may have to be fixed up. For example,
Word 2007's new file formats use different extensions (.dotx, .dotm, .docx, .docm).
You could just stay with the old .dot and .document formats -- Word 2007 will
read and write them -- but you wouldn't be able to use any of the new features
the new formats support. If any of your macros modify menus or toolbars, they
won't work with the ribbon in Word 2007. There are a few other gotchas, but
for the most part the old macros will work just as before.
My second question is: can I use Word 2003, including my VB6 macros,
in Windows 7?

Yes, absolutely. I have Word 2003, 2007, and 2010 running side by side
(and sometimes simultaneously) in Windows 7 on several computers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top