LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
external usenet poster
 
Posts: 118
Default Changing reference to Word in Excel project

Thanks for getting back with me, Tom. I read through all your references -
thank you! But I didn't see anything that turned a light on.

"Tom Ogilvy" wrote in message
...
I suspect there is more to your code than what you show.

**No - except for "Sub" and "End Sub", this is it.

If you reference
an object in Word and it is not fully qualified, then you can create a
non-releasable reference to word. Thus, when you code ends, even though

you
might have issued all the commands to close word, it may still remain in
memory. The code you show appears to be designed to execute multiple

times
in a session, so you could be filling memory with copies of word and

causing
the intermittent problems you describe.

**No, it's only executing once - or I should say for the first time!
Although I do call the entire Sub multiple times, it always runs through to
End Sub. And I had no problems with Word hanging on in the 2000
environment.

So the code you show does appear to use late binding - thus you don't need

a
reference to the word object library

**So I did something right for a change!

(use the value of any word constants
rather than using defined constant name.)

**This went over my head.

Make sure you issue the proper commands to close word

**But if I close Word, won't I also close the document I just opened to
view? Again, I had no issues in the 2000 world. That's not to say
everything was coded kosher - just that it worked.

Fully qualify all object references to objects in word and release them at
the end.

**So I need to "Set WD = Nothing" at the end? Okay - but I'm not getting
there at this time.

If you have the patience, any further help is greatly appreciated.
Ed

"Ed" wrote in message
...
Bob and Tom:

Thank you for your responses. But I thought I *was* using late binding.
Sometimes, though, it will error on the Open command - Object required.
Other times it will lock up and not proceed; when I close through Task
Manager, I have a "ghost" doc created. My code is below - if you can

help
me understand what I'm missing, I will be most grateful.

Ed

Dim WD As Object
Dim doc As String
Dim Fname As String
Dim Fpath As String

' Get file path
Fpath = ThisWorkbook.Path

' Check if ActiveCell is in Col C
Sheets("Sheet1").Activate
If ActiveCell.Column = 3 Then

' Get TIR number from list page
Fname = ActiveCell.Text

' Open TIR
doc = Fpath & "\" & Fname & ".doc"
Set WD = CreateObject("Word.Application")
WD.Documents.Open doc
WD.Visible = True

Else
MsgBox "Please select a TIR number in Column C using a single mouse
click."



 
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
Changing a word document into an excel spreadsheet aganchingco Excel Discussion (Misc queries) 7 October 26th 06 11:39 PM
Changing word case in Excel doc Brent Excel Discussion (Misc queries) 2 July 8th 05 09:03 PM
changing a Word doc to Excel Bob Excel Programming 1 April 23rd 04 09:55 PM
Changing project desktop icon Peter[_35_] Excel Programming 0 February 3rd 04 12:36 AM
how to remove a reference from Excel project? A J Excel Programming 0 October 23rd 03 05:11 PM


All times are GMT +1. The time now is 12:28 PM.

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

About Us

"It's about Microsoft Excel"