How to open specific version of Word 2007/2010 in Excel

前端 未结 5 1284
借酒劲吻你
借酒劲吻你 2020-12-11 16:20

I have both Word 2007 and 2010 installed. I need to open Word from within Excel but I need to specify which version I need to open within VBA.

I\'ve tried late bindi

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-11 16:55

    This is a work around:

    TaskID = Shell("C:\Program Files\Microsoft Office\Office12\WINWORD.EXE",vbHide) '2007
    'TaskID = Shell("C:\Program Files\Microsoft Office\Office14\WINWORD.EXE",vbHide) '2010
    GetObject(,"Word.Application")
    

    You would also need to test if a previous version of word is open, or use something other than a basic GetObject to activate the window, else there's no guarantees that it will get the right version.

    The other way would be to pass the document name in the Shell command, and then GetObject could be called with the document name

提交回复
热议问题