K
ker_01
I rarely play in Word, so I'm unfamiliar with the sytax. Using Excel2007 to
grab Word2007 data.
I have a Word document that I can open with Excel, grab data, and close the
file.
However, during some testing, it would be much easier if I could just grab
the data from the open Word instance without opening/closing the file each
time to make an edit, and then run the Excel code to re-open and re-close the
file.
So what was originally: (snippets to save space)
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
'instantiate Word and open document
Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Open(sFile)
'do stuff
wdDoc.Close False
wdApp.Quit
Set wdDoc = Nothing
Set wdApp = Nothing
Might become something more like:
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Set wdDoc = wdApp.ActiveDocument
'do stuff
But that isn't working- I'm getting RTE 91: Object variable not set
Any suggestions? I just need to set wdDoc to whatever Word document is
currently active/selected, then I should be fine.
Thanks!
Keith
grab Word2007 data.
I have a Word document that I can open with Excel, grab data, and close the
file.
However, during some testing, it would be much easier if I could just grab
the data from the open Word instance without opening/closing the file each
time to make an edit, and then run the Excel code to re-open and re-close the
file.
So what was originally: (snippets to save space)
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
'instantiate Word and open document
Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Open(sFile)
'do stuff
wdDoc.Close False
wdApp.Quit
Set wdDoc = Nothing
Set wdApp = Nothing
Might become something more like:
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Set wdDoc = wdApp.ActiveDocument
'do stuff
But that isn't working- I'm getting RTE 91: Object variable not set
Any suggestions? I just need to set wdDoc to whatever Word document is
currently active/selected, then I should be fine.
Thanks!
Keith