Printing Invoices from a List of URL's in Excel

ExcelHelp2025

New Member
Joined
Jan 31, 2025
Messages
1
Office Version
  1. 2011
Platform
  1. 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 ?
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
 

Forum statistics

Threads
1,226,771
Messages
6,192,918
Members
453,766
Latest member
Gskier

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top