Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
convert excel document to word document (not a picture) | Excel Discussion (Misc queries) | |||
Make a Word event macro fire in active document | Excel Programming | |||
How do I convert a word document into a Excel document | Excel Discussion (Misc queries) | |||
How to change a excel document into a word document? | Excel Discussion (Misc queries) | |||
Macro to copy cell data to word document based on an active row? | Excel Programming |