Error 462: The remote server machine does not exist when working with Word via Excel VBA

后端 未结 3 1278
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 02:08

I open a Word file programmatically in Excel VBA and add/edit contents using bookmarks.

I find that on alternate runs, I get

Error 462: The re

3条回答
  •  借酒劲吻你
    2020-12-04 02:15

    You have two unqualified references to Word objects:

    objSelection.Style = ActiveDocument.Styles("Heading 1")
    

    which appears twice, needs to be:

    objSelection.Style = objWord.ActiveDocument.Styles("Heading 1")
    

    Otherwise you're creating an implicit reference to Word that you can't destroy in your code.

提交回复
热议问题