我有一小程式如下:當我第一次按commandButton時可順利將資料送至WORD,再把WORD關閉,完成後按OK,但第二次再按CommandButton時卻出現:[執行階段錯誤'462':遠端伺服器不存在或無法使用]的錯誤訊息,請問各路高手,我該如何解決這個問題(我已經試過好多種方法並研究好幾天了),拜託各位高手不吝指教,先謝了。
作業系統:Win98 & VB6.0中文企業版 & Word97
我的程式碼如下:
Private Sub Command1_Click()
Dim wd As Word.Application
Dim ww As Document
Set wd = New Word.Application
Set ww = wd.Documents.Add
wd.Visible = True
' 錯誤出現在下面這行
AppActivate wd.Application.Caption
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2, NumColumns:=6
Selection.TypeText Text:="客戶編號"
Selection.MoveRight Unit:=wdCell
MsgBox "Ok.."
On Error Resume Next
wd.Quit False
Set wd = Nothing
Set ww = Nothing
End Sub