In order to open files with a cmd button, I use below code:
The module:
Code for cmd button:
This works fine, and I can choose a relative link (relative to the database) or a direct link (c:\folder\file.docx).
I would like to proceed a bit, and also print the linked files from a button, and preferably without opening the files, if possible. Or perhaps, as Windows when right-clicking on af file and click Print (opening the file, print it, and close it again). I would also like to be able to write wnated copies in a text box, and then that specific number of copies should be printed.
Is this at all possible?
EDIT: Forgot to include, that I can also open files on a server location, like:
[http://sirius-offline/DKOs/M-CPH-1171-17987_EN.dot]
and I would of course also like to be able to print them.
The module:
Code:
Option Compare Database
Option Explicit
Public Const SW_HIDE = 0
Public Const SW_NORMAL = 1
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_MAXIMIZE = 3
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
Public Const SW_MAX = 10
Public Const SW_SHOWDEFAULT = 10
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Public 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
Public Function bimShellOpenFile(strFilePath As String, lngShowCmd As Long) As Long
'
' opens the file passed by calling windows
' the file should be opened into the app associated with the files type
'
Dim r As Long
Dim hwnd As Long
r = ShellExecute(hwnd, "open", strFilePath, "", "", lngShowCmd)
bimShellOpenFile = r
End Function
Code for cmd button:
Code:
Private Sub cmdProcedurePath_Click()
Dim retval As Variant
If Me.txtProcedurePath > "" Then
retval = bimShellOpenFile(Replace(Me.txtProcedurePath, "%dir%", Me.txtDatabasePath), vbNormalFocus) ' vbNormalFocus True
Else
MsgBox "There is no file to view."
End If
End Sub
This works fine, and I can choose a relative link (relative to the database) or a direct link (c:\folder\file.docx).
I would like to proceed a bit, and also print the linked files from a button, and preferably without opening the files, if possible. Or perhaps, as Windows when right-clicking on af file and click Print (opening the file, print it, and close it again). I would also like to be able to write wnated copies in a text box, and then that specific number of copies should be printed.
Is this at all possible?
EDIT: Forgot to include, that I can also open files on a server location, like:
[http://sirius-offline/DKOs/M-CPH-1171-17987_EN.dot]
and I would of course also like to be able to print them.
Last edited: