ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening Word with a specific document from excel vba (https://www.excelbanter.com/excel-programming/314298-opening-word-specific-document-excel-vba.html)

JRB

Opening Word with a specific document from excel vba
 
Is it possible to open Word with a specific document from an excel procedure

I have managed to open word using:
Application.ActivateMicrosoftApp xlMicrosoftWord
but can find no way to specify the document to load

I would like to run a mail merge, using Word, to create some mailing labels,
print them and then return to Excel and closing the Word program

Any (and all) suggestions greatly appreciated

TIA



JRB

PS Opening Word with a specific document from excel vba
 
I omitted to mention that the procedures have to be compatible with Excel 97

"JRB" wrote in message
...
Is it possible to open Word with a specific document from an excel

procedure

I have managed to open word using:
Application.ActivateMicrosoftApp xlMicrosoftWord
but can find no way to specify the document to load

I would like to run a mail merge, using Word, to create some mailing

labels,
print them and then return to Excel and closing the Word program

Any (and all) suggestions greatly appreciated

TIA





Ron de Bruin

Opening Word with a specific document from excel vba
 
Hi JRB

Try this example that print a Word file

Sub test()
Dim WD As Object
Set WD = CreateObject("Word.Application")
WD.Documents.Open ("C:\ron.doc")
WD.ActiveDocument.PrintOut Background:=False
WD.ActiveDocument.Close
WD.Quit
Set WD = Nothing
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"JRB" wrote in message ...
Is it possible to open Word with a specific document from an excel procedure

I have managed to open word using:
Application.ActivateMicrosoftApp xlMicrosoftWord
but can find no way to specify the document to load

I would like to run a mail merge, using Word, to create some mailing labels,
print them and then return to Excel and closing the Word program

Any (and all) suggestions greatly appreciated

TIA





sa3214[_2_]

Opening Word with a specific document from excel vba
 
Thanks Ron ... That definitely works a treat
Unfortunately it printed the document before the mailmerge took place
Have you any suggestions as to how I can force the mailmerge prior to
printing

Thanks again from the prompt and accurate response
This NG must be one of the best

"Ron de Bruin" wrote in message
...
Hi JRB

Try this example that print a Word file

Sub test()
Dim WD As Object
Set WD = CreateObject("Word.Application")
WD.Documents.Open ("C:\ron.doc")
WD.ActiveDocument.PrintOut Background:=False
WD.ActiveDocument.Close
WD.Quit
Set WD = Nothing
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"JRB" wrote in message
...
Is it possible to open Word with a specific document from an excel
procedure

I have managed to open word using:
Application.ActivateMicrosoftApp xlMicrosoftWord
but can find no way to specify the document to load

I would like to run a mail merge, using Word, to create some mailing
labels,
print them and then return to Excel and closing the Word program

Any (and all) suggestions greatly appreciated

TIA







Ron de Bruin

Opening Word with a specific document from excel vba
 
I never try that

Maybe David's site have a answer for you
http://www.mvps.org/dmcritchie/excel/mailmerg.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl


"sa3214 @eclipse.co.uk" <jimburton<REMOVE wrote in message ...
Thanks Ron ... That definitely works a treat
Unfortunately it printed the document before the mailmerge took place
Have you any suggestions as to how I can force the mailmerge prior to printing

Thanks again from the prompt and accurate response
This NG must be one of the best

"Ron de Bruin" wrote in message ...
Hi JRB

Try this example that print a Word file

Sub test()
Dim WD As Object
Set WD = CreateObject("Word.Application")
WD.Documents.Open ("C:\ron.doc")
WD.ActiveDocument.PrintOut Background:=False
WD.ActiveDocument.Close
WD.Quit
Set WD = Nothing
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"JRB" wrote in message ...
Is it possible to open Word with a specific document from an excel procedure

I have managed to open word using:
Application.ActivateMicrosoftApp xlMicrosoftWord
but can find no way to specify the document to load

I would like to run a mail merge, using Word, to create some mailing labels,
print them and then return to Excel and closing the Word program

Any (and all) suggestions greatly appreciated

TIA









jason

PS Opening Word with a specific document from excel vba
 
To open the word application and then a specific document I use late
binding and the following code (you need to replace
"H:\DriveName\FolderName\MyDocument.Doc" with your own document and
pathway):

Dim WordApplication As Object

Sub OpenFileNote()

Call OpenWord

With WordApplication
.WindowState = 1
.Visible = True
.documents.Open
Filename:="H:\DriveName\FolderName\MyDocument.Doc"
End With

End Sub

Private Function OpenWord()

Dim strApp As String
strApp = "Word.Application"
'check to see if Word is running
On Error Resume Next
If Not IsRunning(strApp) Then
Set WordApplication = CreateObject(strApp)
Else
Set WordApplication = GetObject(, strApp)
End If
On Error GoTo 0
strApp = ""

End Function

Public Function IsRunning(ByVal myAppl As String) As Boolean

Dim applRef As Object
On Error Resume Next

Set applRef = GetObject(, myAppl)

If Err.Number = 429 Then
IsRunning = False
Else
IsRunning = True
End If

Set applRef = Nothing

End Function

(EARLY BINDING IS THE OTHER APPROACH)

HOPE THIS HELPS
JASON

"JRB" wrote in message ...
I omitted to mention that the procedures have to be compatible with Excel 97

"JRB" wrote in message
...
Is it possible to open Word with a specific document from an excel

procedure

I have managed to open word using:
Application.ActivateMicrosoftApp xlMicrosoftWord
but can find no way to specify the document to load

I would like to run a mail merge, using Word, to create some mailing

labels,
print them and then return to Excel and closing the Word program

Any (and all) suggestions greatly appreciated

TIA




All times are GMT +1. The time now is 05:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com