我安裝了Word 2007和2010。我需要從Excel中打開Word,但我需要指定在VBA中需要打開哪個版本。如何在Excel中打開特定版本的Word 2007/2010
我已經試過後期綁定
Dim wordApp2007 As Object
Dim wordApp2010 As Object
Set wordApp2007 = CreateObject("Word.Application.12")
wordApp2007.Visible = True
Set wordApp2010 = CreateObject("Word.Application.14")
wordApp2010.Visible = True
但都打開Word 2010
我也用
Dim wordApp As Word.Application
Set wordApp2007 = New Word.Application
wordApp2007.Visible = True
,並設置引用到Word 12.0對象嘗試早期綁定模型,但這仍然打開Word 2010
如果我使用
"C:\Program Files\Microsoft Office\Office12\WINWORD.EXE" /regserver
"C:\Program Files\Microsoft Office\Office14\WINWORD.EXE" /regserver
註冊Word的每個版本再註冊的版本打開,但我就不能開開非註冊。
任何人都可以幫助並告訴我如何使用VBA在Excel中打開特定版本的Word?
謝謝
編輯:示例代碼....
Option Explicit
Dim wordApp2007 As Word.Application
Sub Word_InfoEarly()
'early binding
Set wordApp2007 = New Word.Application
wordApp2007.Visible = True
'other Stuff
Stop
wordApp2007.Quit
Set wordApp2007 = Nothing
End Sub
Sub Word_InfoLate()
Dim wordApp2007 As Object
Dim wordApp2010 As Object
Set wordApp2007 = CreateObject("Word.Application.12")
wordApp2007.Visible = True
Set wordApp2010 = CreateObject("Word.Application.14")
wordApp2010.Visible = True
'other Stuff
Stop
wordApp2007.Quit
Set wordApp2007 = Nothing
wordApp2010.Quit
Set wordApp2010 = Nothing
End Sub
您可以發佈創建對象的代碼,然後調用註冊版本的MS Word? – EastOfJupiter
我編輯了我的問題,以顯示對象的聲明和分配 – user3357963
我不清楚。我道歉,但我想要整個子程序。如果沒有整塊,很難看到可能會丟失或不正確。 – EastOfJupiter