我想通過與Documents.Open的字符串打開一個單詞.docm文件。它工作並打開文件,但在WordHandle.Documents(x).Name內部,它始終是「Document1」。另外打開的文檔被命名爲「Document1」VBA Documents.Open名稱=始終「Document1」
我在做什麼錯?
Sub FileOpen(ByVal fileName As String)
If Not gb_WordObjSet Then
Exit Sub
End If
If Not FileExists(fileName) Then
Exit Sub
End If
With gh_WordObject
.Documents.Open fileName:=fileName, OpenAndRepair:=True
With .ActiveWindow.View
.Type = 3
.ShowAll = True
End With
End With
End Sub
fileName例如, =「C:\ TEMP \ 20150702161254.docm」
gh_WordObject初始化這樣
Set gh_WordObject = CreateObject("Application.Word")
我們可以看一下你的代碼的其餘部分? – Dportology
我更新了代碼 – Megamind
你如何初始化'gh_WordObjSet'? – EngJon