Activating an opened word document for VBA control

  • Good Morning,


    I was wondering if anyone could help with this piece of code. At the most basic level what I am trying to do is open a word document from Excel, and then control that word document through VBA, to either print/complete a mail merge, or do anything else that might be required. The code I have is as below:


    Up to the red part, the code works fine i.e. it at the very least opens the word document I want to control. But once I get to the red piece of code I get an error message "Run time error 424 - object required". It seems to me as though maybe the document isn't properly activated. I have had a look on other forums, and changed the code to X.Activedocument etc, but this doesn't seem to make any difference. I hope someone can help with this.


    Thanks,


    Mark [/COLOR]

  • Re: Activating an opened word document for VBA control


    Mark, the red highlighting of erroneous code does not show up. can you clarify which line of code is causing the error? In Excel, did you add the reference for Microsoft Word?

  • Re: Activating an opened word document for VBA control


    Sjeter,


    Thank you for your response. Apologies for the code not being highlighted, it was the part starting ActiveDocument.SaveAs. However as you rightly pointed out Microsoft Word was not correctly referenced in the VBA. I have changed this and my problem has now been solved!


    Thanks,


    Mark

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!