View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Obtaining Active Document Name from WORD for Excel procedure

Tim,
Bear in mind that if you have more than one instance of Word, GetObject will
you one instance essentially randomly.
So it would depend if this is a concern for you.

NickHK

"Tim Childs" wrote in message
...
Chip, Nick

Many thanks for the response including the reference in the Tools

Library -
I would not have spotted this otherwise

best wishes

Tim


"Chip Pearson" wrote in message
...
Try the following:

Dim WordApp As Object
Set WordApp = GetObject(, "Word.Application")
If Not WordApp.ActiveDocument Is Nothing Then
MsgBox "Active Document: " & WordApp.ActiveDocument.FullName
End If

Change FullName to Name if you don't want the path information.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Tim Childs" wrote in message
...
Hi

I want to return the name of the active document from WORD from
within an
Excel macro i.e. the macro in the workbook interrogates WORD to
find the
name of the currently active document.

Any help gratefully received

Thanks

Tim