0

So I had this code in Excel VBA:

Dim oWord As New Word.Application
Dim objDoc
Set objDoc = oWord.Documents.Open("C:\folder\document.docx")

But now instead of having document.docx as an external Word document I embedded it on a sheet as an object (Object 1). Therefore, I want to edit the code above to access the object instead of the external file.

In other words I want the code to be something like this:

'Set objDoc = oWord.Documents.Open(Object 1)

I have seen the question here, but I want the line of code above and it doesn't explain how to do it.

Thanks

Saeed
  • 1
  • 1
  • The question you linked to *does* explain how to do it though.. it's a quite different approach if the document is embedded. – BigBen Jun 30 '20 at 16:44
  • If it does explain it then I probably don't understand, can you post how the new line of code is supposed to be? – Saeed Jun 30 '20 at 16:46
  • [This](https://stackoverflow.com/questions/54419143/edit-word-document-embedded-in-a-workbook-and-save-as-copy) may be a better question to reference actually. I think it's doing something similar to what you want. – BigBen Jun 30 '20 at 17:16
  • Thank you. I will look at it. It seems to have a different approach but as you said, it has the same purpose I want. – Saeed Jun 30 '20 at 18:18

1 Answers1

0

What I did eventually was use .SaveAs to "export" the embedded document in a certain location, then run my code using the exported document and delete it in the end. This works for the purpose of my code.

Saeed
  • 1
  • 1