以下是我的程式 ﹕
Private Sub Print_Out()
Dim wdapp As Word.Application
  Dim mydoc As Word.Document
  Set wdapp = CreateObject("word.application")
  wdapp.Visible = True
  wdapp.Documents.Add
  Set mydoc = wdapp.ActiveDocument
       :
       :
  wdapp.ActiveDocument.SaveAs Doc_Path & pol_num & ".doc"
  wdapp.ActiveDocument.Close
  wdapp.DDETerminateAll
  
  wdapp.Quit
  Set wdapp = Nothing
End Sub
為何如果連續執行二次會出現錯誤如下﹕
Run-time error '462'
The remote server machine does not exist or is unavailable
又如果已經開啟一個Word的視窗而執行此程式﹐又會出現以下錯誤﹕
Run-time error '5850'
The specified range is not from the correct document or story
請各位高手指點﹐謝謝
arrow
arrow
    全站熱搜

    vbqa 發表在 痞客邦 留言(0) 人氣()