Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default printing an external document

I am using a VBA control - Command button. and I would like to be able to
print a word document by pressing it. The file is a fax cover sheet, which is
an important part of the application I am making.

Is there anyway this can be achieved.

Thank you to all who are able to help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default printing an external document

Steve

This automates Word from Excel and uses early binding, so you would need to
set a reference to the MS Word library under references... in the VBE
(Alt+F11) before running the code

Sub AutomateWord()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Open("C:\FaxCover.doc")
wdDoc.PrintOut
wdDoc.Close SaveChanges:=False
Set wdDoc = Nothing
wdApp.Quit
Set wdApp = Nothing
End Sub

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


"Steve" wrote in message
...
I am using a VBA control - Command button. and I would like to be able to
print a word document by pressing it. The file is a fax cover sheet, which
is
an important part of the application I am making.

Is there anyway this can be achieved.

Thank you to all who are able to help


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default printing an external document

Steve,
Maybe the ShellExecute API with the Operation set to "print". Then you do
not need to know which application to open; the default for that file type
is used.

Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String,
ByVal nShowCmd As Long) As Long

Dim RetVal As Long

RetVal = ShellExecute(&O0, "print", "C:\Doc.doc", vbNullString,
vbNullString, &O0)
If RetVal <= 32 Then
MsgBox "Error: Cannot print"
End If

NickHK

"Steve" wrote in message
...
I am using a VBA control - Command button. and I would like to be able to
print a word document by pressing it. The file is a fax cover sheet, which

is
an important part of the application I am making.

Is there anyway this can be achieved.

Thank you to all who are able to help



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
Excel 2003 printing problem--printing 1 document on 2 pages Bons Excel Discussion (Misc queries) 0 December 24th 09 04:15 PM
About printing a document FiluDlidu Excel Discussion (Misc queries) 3 February 3rd 09 12:14 AM
Automating a printing of pages that are Hyperlinked to external so Wiz Excel Worksheet Functions 0 January 11th 08 03:35 PM
Not printing whole document syssupspe Excel Discussion (Misc queries) 2 April 9th 07 01:02 PM
Printing and Document Name Wayne Blosat Excel Programming 1 August 23rd 03 06:45 PM


All times are GMT +1. The time now is 08:18 AM.

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"