为什么再次按command总是出现“远程服务器不存在或不能使用”,还只能请专家帮助了。谢谢
代码如下:
Private Sub Command1_Click()
Dim wordApp
Dim Word
Set wordApp = CreateObject("Word.Application")
Set Word = wordApp.Documents.Open(App.Path & "\历史记录\施工收费核定清单(模板).doc")
wordApp.Visible = True
Selection.MoveDown Unit:=wdParagraph, Count:=2 '***************************第一次按Command没有问题,再一次按时,指出此处错误
Selection.MoveRight Unit:=wdCharacter, Count:=6
Selection.TypeText Text:=Text2
Selection.MoveDown Unit:=wdParagraph, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=6
Selection.TypeText Text:=Text3
Selection.MoveDown Unit:=wdParagraph, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=6
Selection.TypeText Text:=Combo2.Text
Selection.MoveDown Unit:=wdParagraph, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=7
Selection.TypeText Text:=Text52
Word.SaveAs App.Path & "\历史记录" & Text34 & ".doc"
Word.Close
Set Word = Nothing
wordApp.Quit
Set wordApp = Nothing
End Sub
[最优解释]
我如下测试没有问题:
Private Sub Command1_Click()
Dim wordApp
Dim Word
Set wordApp = CreateObject("Word.Application")
Set Word = wordApp.Documents.Open(App.Path & "\历史记录\施工收费核定清单(模板).doc")
wordApp.Visible = True
wordApp.Selection.MoveDown Unit:=wdParagraph, Count:=2 '***************************第一次按Command没有问题,再一次按时,指出此处错误
wordApp.Selection.MoveRight Unit:=wdCharacter, Count:=6
'wordApp.Selection.TypeText Text:=Text2
'wordApp.Selection.MoveDown Unit:=wdParagraph, Count:=1
'wordApp.Selection.MoveRight Unit:=wdCharacter, Count:=6
'wordApp.Selection.TypeText Text:=Text3
'wordApp.Selection.MoveDown Unit:=wdParagraph, Count:=1
'wordApp.Selection.MoveRight Unit:=wdCharacter, Count:=6
'wordApp.Selection.TypeText Text:=Combo2.Text
'wordApp.Selection.MoveDown Unit:=wdParagraph, Count:=1
'wordApp.Selection.MoveRight Unit:=wdCharacter, Count:=7
'wordApp.Selection.TypeText Text:=Text52
Word.SaveAs App.Path & "\历史记录" & Text34 & ".doc"
Word.Close
Set Word = Nothing
wordApp.Quit
Set wordApp = Nothing
End Sub