Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell printing and close 1

Status
Not open for further replies.

royalcheese

Technical User
Dec 5, 2005
111
GB

I have this code

Code:
retval = Shell("c:\program files\microsoft office\office11\winword.exe T:\EAD\Letters\Receipt_address_change.doc")

This opens up me file, but , i want to print and close it after this and not let the user print.

Thanks in advance ,

chris
 
The shell process will only initially execute the application (in this case, Word). You will need to open the Word application as an object in your VB app so that you can perform the print and close functions. The example used in the reply above from the Microsoft KB is an MSAccess / MSWord process, but the coding is the same for your app.

Philip
 
Then there's also the ShellExecute API.

[tt]' declaration section
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

' then in a sub
ShellExecute hwnd, "Print", "T:\EAD\Letters\Receipt_address_change.doc", _
vbNullString, vbNullString, 0[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top