Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving from Office 2002/3 to 2010

Status
Not open for further replies.

Andrzejek

Programmer
Jan 10, 2006
8,486
5
38
US

We are in the process of moving our VB6 application from MS Office 2002/2003 to Office 2010.
I would like to be ready when the move happen, so I tried to use code for both version:
Code:
With ObjWord
    ...
    If .Application.Version < 13 Then
        [green]'Office 2002 & 2003[/green]
        .MailingLabel.CreateNewDocument Name:="5162", _
            Address:="", AutoText:="ToolsCreateLabels1"
    Else
        [green]'Office 2010[/green][blue]
        .MailingLabel.[highlight]CreateNewDocumentByID[/highlight] LabelID:="1359804673", _
                Address:="", AutoText:="ToolsCreateLabels1", _
                LaserTray:=wdPrinterManualFeed, _
                ExtractAddress:=False, _
                PrintEPostageLabel:=False, _
                Vertical:=False[/blue]
    End If
    ...
End With
But when I run it on a machine with Office 2003, the [blue]BLUE[/blue] code gives me an error ("Method or data member not found") and highlights the code because is not recognized by the (VBA?) compiler. And I am pretty sure if I would run it on the machine with Office 2010 the first IF statement would (probably) give me an error.

Is there any way I can be ready for both versions of Office (2003 and 2010) in my VB 6 code for the transition time?


Have fun.

---- Andy
 
Andy,

In this case, wouldn't you have to have a project reference to both office products?

If at first you don't succeed, then sky diving wasn't meant for you!
 

I would guess you are right. The problem is, you can not have Office 2002/2003 loaded on the same machine as Office 2010. I think they install in the same location, plus one is 32-bit, another os 64-bit.

My 'work around' approach now is to have the blue code commented out so I can un-comment it when I needed it.

Have fun.

---- Andy
 
I would suggest using late binding instead of explicit library references.
 
The problem is, you can not have Office 2002/2003 loaded on the same machine as Office 2010.
Only not if you install with default settings. If you customise the installation, installing Office 2010 in, say "C:\Programs\O2k10\" and Office 2003 in "C:\Programs\O2k03" you should be able to install both versions all right.

You just cannot have more than one Outlook installed. All other Office apps should not pose a problem.

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Use late binding

Restrict yourself to VBA code which runs on the lowest version later versions will generally accept it; do not make use of new features in the later version(s)

Alternatively if new features in a later version are to be used you could try (I hav'nt yet!) something like;

Dim ObjApp as Object
Set ObjApp = CreateObject("SomeOffApp")

If ObjApp.Version >n then
Call Sub2DoItTheNewWay
Else
Call SubDoItTheOldWay
End if

that may prevent the code running into places where it can't understand everything.
 

Thank you for your suggestions, all good.

I was thinking about late binding for some time now (I know, just 'thinking' about it is not enough), but with others in the team and many programs in the system, that would require a lot of changes so commenting the code out for now looks like a best option for me.

As far as installing Office 2010 in other location - all our users run our app out of Citrix server and I am pretty sure it has just regular installation path, so we need to have the same set up as Citrix machines.


Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top