Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Obtaining Active Document Name from WORD for Excel procedure

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Obtaining Active Document Name from WORD for Excel procedure

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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Obtaining Active Document Name from WORD for Excel procedure

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






  #4   Report Post  
Posted to microsoft.public.excel.programming
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








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Obtaining Active Document Name from WORD for Excel procedure

Tim

No error checking or fancy stuff, but here is the theory. Uses early
binding so a reference to the word object lirary with be necessary via
toolsreferences in the VBE

Sub getWordDocName()
Dim wd As New Word.Application
Dim wddoc As Word.Document
Set wd = Word.Application
Set wddoc = wd.ActiveDocument
MsgBox wddoc.Name
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HIS


"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






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
convert excel document to word document (not a picture) frendabrenda1 Excel Discussion (Misc queries) 2 October 6th 06 03:55 PM
Make a Word event macro fire in active document [email protected] Excel Programming 2 March 27th 06 01:00 PM
How do I convert a word document into a Excel document gwiltz2 Excel Discussion (Misc queries) 1 October 22nd 05 07:04 PM
How to change a excel document into a word document? wannaknow Excel Discussion (Misc queries) 1 July 27th 05 09:37 PM
Macro to copy cell data to word document based on an active row? Brian Excel Programming 2 September 16th 04 01:55 PM


All times are GMT +1. The time now is 04:25 AM.

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"