nianchi111
Board Regular
- Joined
- Aug 24, 2007
- Messages
- 197
- Office Version
- 365
Dear,
I have found a code to open .FAZ file and print to .PDF but I have to manually give the file name and select the path to save the pdf file.
Is there a way to loop to print all the files based on column A and to be saved in a different folder with the file name with reference to Column B
Column A has the list of files to be opened and print and in Column B file name to be saved as.
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
Const SW_HIDE As Long = 0&
Const SW_SHOW As Long = 5&
Sub PrintFile(strFilePath As String)
ShellExecute Application.hwnd, "Print", strFilePath, 0&, 0&, SW_HIDE
End Sub
Sub OpenFile(strFilePath As String)
ShellExecute Application.hwnd, "Open", strFilePath, 0&, 0&, SW_SHOW
End Sub
Sub PrintPDFs()
Dim sFile As String
Dim sFolder As String
sFolder = "C:\Users\vkv022\Desktop\test\New\"
sFile = Dir(sFolder & "*.fax")
Do While sFile <> ""
PrintFile sFolder & sFile
sFile = Dir
Loop
End Sub
I have found a code to open .FAZ file and print to .PDF but I have to manually give the file name and select the path to save the pdf file.
Is there a way to loop to print all the files based on column A and to be saved in a different folder with the file name with reference to Column B
Column A has the list of files to be opened and print and in Column B file name to be saved as.
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
Const SW_HIDE As Long = 0&
Const SW_SHOW As Long = 5&
Sub PrintFile(strFilePath As String)
ShellExecute Application.hwnd, "Print", strFilePath, 0&, 0&, SW_HIDE
End Sub
Sub OpenFile(strFilePath As String)
ShellExecute Application.hwnd, "Open", strFilePath, 0&, 0&, SW_SHOW
End Sub
Sub PrintPDFs()
Dim sFile As String
Dim sFolder As String
sFolder = "C:\Users\vkv022\Desktop\test\New\"
sFile = Dir(sFolder & "*.fax")
Do While sFile <> ""
PrintFile sFolder & sFile
sFile = Dir
Loop
End Sub