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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please don't laugh....Its Friday

Status
Not open for further replies.

ICCIIT

Technical User
Jul 21, 2003
62
GB
OK I am working within MS97 Access database....(yes its a bit of a joke now in 2012!)

Anyway, I have some code that intialise MSWord97 dumps some bookmarks, prints and closes.

I now need it to do exactly the same thing but instead of opening Word 97 I want it to open Word 2007 - can this be done or are they too far apart in versions?

We have Office 97 as a default suite but also have 2007 version of Word/Excel installed so its all a bit of mish mash really.

Code:
Dim dbs As Database
   Dim objWord As Object
   Dim PrintResponse
   Set dbs = CurrentDb
   
   'create reference to Word Object
   
   Set objWord = CreateObject("Word.Application")
   
   'Word Object is created - assign bookmarks with data.
   
   With objWord
       .Visible = True

.........

End With

   'Print the document
    objWord.ActiveDocument.PrintOut Background:=False
    
   'release all objects
         
        With objWord
       .Visible = False
       .Quit False

      End With
       
   Set objWord = Nothing
   Set dbs = Nothing

Any help appreciated

 
I believe the issue is not if the code will work, but if you can specify the version. You need to get an Application object of the desired version. Word may be different then Access in that you may be able to specify the version. In Access it will always return the latest version.

This link shows you how.

 
Did you try this ?
Set objWord = CreateObject("Word.Application.12")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I would think it is just going to open the version of Word that is installed on the client, and fail whenever it hits unsupported properties or methods.
 
Thanks Guys, I have left work for the day and will give these ideas a try when next back in, looks encouraging.

MajP: I set the target document to "Open with Word 2007" using the Windows Explorer properties but it still defaulted back to 97 when called by this code.

PHV: Thanks will give that a go first seeing as its probably the simplest possible solution.

VBAJock: It does seem to be doing that at the present.

Will post back next week with any results.
 
I did not suggest anything about Windows Explorer so I am a little confused. Did you actually use the code from the link

Set objWord = CreateOfficeInstance("Word.Application.12", "C:\FileToOpen.mdb")

If that did not work I would be kind of suprised if simply using late binding and specifying the version would work. This code was supposed to handle the cases when simply specifying the version does not work.
 
Hi MajP

When I made my last post I had not tried any suggested solution at that point.

I was trying to explain that I had used the default open properties of the destination Word document within Windows explorer to Open using Word 2007 (the "Open With" option on the General tab)

I have since tried the module on the link but it fell over on the "Replace" command within the function Replace
Code:
Public Function CreateOfficeInstance(ByVal strProgID As String, _
                            ByVal strFilePath) As Object

'The returned path is actually a command line string with parameter for file name as %1
        strCommandLine = [b]Replace[/b](strPath, "%1", strFilePath)

PHV: Have tried your suggestion and it still opened with Word 97 shell and dumped a load of garbage text in to it and bloated it to 400+ pages! (its only a 1 sided document)

I suspect that the version leap between 1997 and 2007 is just too much for it to handle! I will probably have to continue with using both bits of legacy software!

Thanks for your help but its probably not worth wasting any more time over.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top