471,579 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,579 software developers and data experts.

How do you print word doc from switchboard

Ok, I'm having a little trouble finding the correct way to have a word
document print out in the background when selecting it on the
switchboard. Is there any way this can be done? I already found a way
to open up the document using a macro with the RunApp action. Any help
would be greatly appreciated, Thank you

Apr 13 '06 #1
2 2708
Hi,

This code is the best way to open and print any documents type

Regards

Robert Simard
Logipro
http://www.logicielappui.com/tips
'// Code Start
Option Compare Database
Option Explicit

Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9

Private Declare Function GetDesktopWindow Lib "user32" () As Long
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
'Usage : Call RunShellExecute("Open","c:\test.doc", 0&, 0&, SW_SHOWNORMAL)
' Call RunShellExecute("Print","c:\test.doc", 0&, 0&, SW_SHOWNORMAL)
Public Sub RunShellExecute(sTopic As String, sFile As Variant, sParams As
Variant, sDirectory As Variant, nShowCmd As Long)

Dim hWndDesk As Long
Dim success As Long

hWndDesk = GetDesktopWindow()

success = ShellExecute(hWndDesk, sTopic, sFile, sParams, sDirectory,
nShowCmd)

'on error "Open with"
If success = 31 Then
Call Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " & sFile,
vbNormalFocus)
End If

End Sub


Apr 13 '06 #2

Yoman wrote:
Hi,

This code is the best way to open and print any documents type

Regards

Robert Simard
Logipro
http://www.logicielappui.com/tips
'// Code Start
Option Compare Database
Option Explicit

Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9

Private Declare Function GetDesktopWindow Lib "user32" () As Long
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
'Usage : Call RunShellExecute("Open","c:\test.doc", 0&, 0&, SW_SHOWNORMAL)
' Call RunShellExecute("Print","c:\test.doc", 0&, 0&, SW_SHOWNORMAL)
Public Sub RunShellExecute(sTopic As String, sFile As Variant, sParams As
Variant, sDirectory As Variant, nShowCmd As Long)

Dim hWndDesk As Long
Dim success As Long

hWndDesk = GetDesktopWindow()

success = ShellExecute(hWndDesk, sTopic, sFile, sParams, sDirectory,
nShowCmd)

'on error "Open with"
If success = 31 Then
Call Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " & sFile,
vbNormalFocus)
End If

End Sub


I'm kinda new at this, Can you help me step by step? I want to print
it off a switchboard item.

Apr 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Michael Keene | last post: by
1 post views Thread by jimwlee | last post: by
2 posts views Thread by Earl Anderson | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Vinnie | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.