Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Printing to word from excel

I am new to coding and I have a question on how to print a word doc
from excel and place some text on the word doc from the excel file. I
have gotten as far as printing the word doc from excel. I used this
code I found in this group. I have a spot for typing the cusotmer name
and address in the excel file and I would like to have that information
placed in a bookmarked form field in the word doc so it prints out.
Also I would like for the user to see a box that allows them to choose
the printer instead of the print out just going to the default printer.

See below code:

Sub cmdPrintCoverLetter()

Dim bStarted As Boolean
Dim oApp As Word.Application

On Error Resume Next
Set oApp = GetObject(, "Word.Application")
'Get the running instance of Word, if there is no instance
'create a new one:
If Err < 0 Then
bStarted = True
Set oApp = CreateObject("Word.Application")
End If

oApp.Activate
oApp.Visible = True
'Open document
oApp.Documents.Open Filename:="c:\remodel\CoverLetter.doc"

'Print file
oApp.ActiveDocument.PrintOut
oApp.ActiveDocument.Close savechanges:=wddonotsavechanges
'Quit only when Word was not running when we started this code
If bStarted Then
oApp.Quit
End If

Set oApp = Nothing

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Printing to word from excel

I would like to have that information
placed in a bookmarked form field in the word doc so it prints out.

- Why not used a Merged document created in Word and called from Excel?

Also I would like for the user to see a box that allows them to choose
the printer instead of the print out just going to the default printer.

- Instead of this code...
oApp.ActiveDocument.PrintOut
Use this code...
oApp.Dialogs(wdDialogFilePrint).Show

HTH,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


" wrote:

I am new to coding and I have a question on how to print a word doc
from excel and place some text on the word doc from the excel file. I
have gotten as far as printing the word doc from excel. I used this
code I found in this group. I have a spot for typing the cusotmer name
and address in the excel file and I would like to have that information
placed in a bookmarked form field in the word doc so it prints out.
Also I would like for the user to see a box that allows them to choose
the printer instead of the print out just going to the default printer.

See below code:

Sub cmdPrintCoverLetter()

Dim bStarted As Boolean
Dim oApp As Word.Application

On Error Resume Next
Set oApp = GetObject(, "Word.Application")
'Get the running instance of Word, if there is no instance
'create a new one:
If Err < 0 Then
bStarted = True
Set oApp = CreateObject("Word.Application")
End If

oApp.Activate
oApp.Visible = True
'Open document
oApp.Documents.Open Filename:="c:\remodel\CoverLetter.doc"

'Print file
oApp.ActiveDocument.PrintOut
oApp.ActiveDocument.Close savechanges:=wddonotsavechanges
'Quit only when Word was not running when we started this code
If bStarted Then
oApp.Quit
End If

Set oApp = Nothing

End Sub


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
Embedding Word Docs into Excel Worksheets and Then Printing The Word Docs mr_melvis Excel Worksheet Functions 1 April 8th 05 03:00 AM
Printing MS Word Doc From MS Excel Anthony Excel Discussion (Misc queries) 2 March 16th 05 08:37 AM
Excel VBA printing to MS Word cause MS Word to crash, why? alruff Excel Programming 0 October 4th 04 09:57 PM
Printing Word Document using Excel Programming hangs Word Alan Excel Programming 0 September 30th 04 08:41 PM
Printing a Word doc from Excel Danny[_4_] Excel Programming 18 October 27th 03 03:13 PM


All times are GMT +1. The time now is 10:20 PM.

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

About Us

"It's about Microsoft Excel"