Export to PDF missing single image

john316swan

Board Regular
Joined
Oct 13, 2016
Messages
57
I updated an image, and now my code no longer works when exporting to PDF. All of the other images and data export, but a single image (that takes up the whole page) does not get exported. I can't seem to find a solved answer anywhere, please help!

Here is my code:
VBA Code:
Option Explicit
Public problemChild As Integer

Sub DigitalPrint()
    Dim OL As Worksheet, CW As Worksheet
    Dim ExportCopy As String, fName As String
    Dim StartRow As Integer, EndRow As Integer, x As Integer
    Dim FSO As Scripting.FileSystemObject
    
    With Application
        .EnableEvents = False
        .ScreenUpdating = False
    End With
    
    Set OL = Worksheets("ValueLetter")
    Set FSO = New Scripting.FileSystemObject
    
    If problemChild = 0 Then
        StartRow = Range("StartRow")
    Else
        StartRow = problemChild
    End If
    EndRow = Range("EndRow")
    
    'Here we create a directory for the exports on the users Desktop with today's date
    ExportCopy = Environ("UserProfile") & "\Desktop\Value Letters\" & Format(Now, "mm-dd-yyyy") & "\"
    If Not FSO.FolderExists(ExportCopy) Then CreateFolderRecursive (ExportCopy)
    
    'Now we begin the export loop
    OL.Select
    For x = StartRow To EndRow
        
        On Error GoTo errorMessage
        Range("RowIndex") = x
        If Range("ErrorCount") > 0 Then GoTo errorMessage
        
        'As a safeguard, will pause one second to ensure the right data is being exported
        'Application.Wait (Now + TimeValue("0:00:01"))
        fName = Range("BF9") & ", " & Range("BF8") & " " & Range("BG7") & " Value Letter"
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, fileName:=ExportCopy & fName, Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, IgnorePrintAreas:=False

    Next x
  
    MsgBox "PDFs Exported!"

    With Application
        .EnableEvents = True
        .ScreenUpdating = True
    End With

Exit Sub

errorMessage:
    With Application
        .EnableEvents = True
        .ScreenUpdating = True
    End With
problemChild = x
MsgBox ("Critical error on student number: " & x & " (" & Range("BG7") & " " & Range("BG8") & ") . You will need to restart the loop at this student once you fix the error!")

End Sub
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Watch MrExcel Video

Forum statistics

Threads
1,122,437
Messages
5,596,130
Members
414,043
Latest member
thomas Stein

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
Top