Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Syntax to pull from data *open*Word instance? (XL2007)
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Syntax to pull from data *open*Word instance? (XL2007)
Got it- just needed Set wdApp = Word.Application Sorry for the bandwidth! "ker_01" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I pull Word data into Excel? | Excel Discussion (Misc queries) | |||
Syntax for 'search' in Horizontal range? XL2007 | Excel Worksheet Functions | |||
Trying to pull data from multiple sheets (and Word docs too) | Excel Discussion (Misc queries) | |||
How to open a new instance of Word and its .doc file | Excel Worksheet Functions | |||
Excel pull data based upon one specific word between two date | Excel Worksheet Functions |