ExcelHelp2025
New Member
- Joined
- Jan 31, 2025
- Messages
- 1
- Office Version
- 2011
- Platform
- Windows
Hi Folks,
I was hoping someone could lend a hand and send me a VBA script I can Insert into an excel spreadsheet, to print a list of invoices which are connected to URLs
Thanks in advance
This is the code I have so far, can anyone help fix it ?
I was hoping someone could lend a hand and send me a VBA script I can Insert into an excel spreadsheet, to print a list of invoices which are connected to URLs

Thanks in advance
This is the code I have so far, can anyone help fix it ?
VBA Code:
Dim lngMyRow As Long
Dim lngLastRow As Long
Dim lngArrayCount As Long
Dim wsFileNames As Worksheet
Dim wsFilePaths As Worksheet
Dim strFullPath As String
For lngMyRow = 2 To lngLastRow 'Start at Row 2. Change to suit.
If StrConv(wsFileNames.Range("A" & lngMyRow), vbLowerCase) = "x" Then
strFullPath = Evaluate("IFERROR(VLOOKUP('" & wsFileNames.Name & "'!A" & lngMyRow & ",'" & wsFilePaths.Name & "'!A:A,1,FALSE),"""")")
If Len(strFullPath) > 0 Then
Call OpenPrintClosePDF(strFullPath)
End If
End If
Next lngMyRow
Application.ScreenUpdating = True
End Sub
Sub OpenPrintClosePDF(strFullPath As String)
Dim objWordApp As Object
Dim objTask As Object
Dim blnWasFileOpen As Boolean
Dim strFileName As String
Set objWordApp = CreateObject("Word.Application")
strFileName = Right(strFullPath, Len(strFullPath) - InStrRev(strFullPath, "\"))
For Each objTask In objWordApp.Tasks
If InStr(objTask.Name, strFileName) > 0 Then
blnWasFileOpen = True
Exit For
End If
Next objTask
CreateObject("Shell.Application").Namespace(0).ParseName(strFullPath).InvokeVerb ("Print") '[URL='http://www.utteraccess.com/forum/Print-file-ShellExecute-t1947546.html']UtterAccess.com[/URL]
If blnWasFileOpen = False Then
For Each objTask In objWordApp.Tasks
If InStr(objTask.Name, strFileName) > 0 Then
objTask.Close
Exit For
End If
Next objTask
End If
Set objWordApp = Nothing
End Sub
Sub Macro()
End Sub