Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I pull Word data into Excel? CaRT6128 Excel Discussion (Misc queries) 0 March 1st 10 10:56 PM
Syntax for 'search' in Horizontal range? XL2007 ker_01 Excel Worksheet Functions 2 October 6th 09 04:11 PM
Trying to pull data from multiple sheets (and Word docs too) ShaunRichard Excel Discussion (Misc queries) 1 January 24th 08 09:02 PM
How to open a new instance of Word and its .doc file Launchnet Excel Worksheet Functions 3 June 18th 07 06:20 PM
Excel pull data based upon one specific word between two date klmiura Excel Worksheet Functions 7 October 26th 06 09:46 PM


All times are GMT +1. The time now is 11:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"