White border by exporting excel to pdf VBA macro

Wimmo83

New Member
Joined
Jun 16, 2015
Messages
1
Dear members,

I have developed a macro to export from excel to PDF.

The strange thing is when I run the macro directly from the VBA editor, the PDF file looks proper.

However when I use a button to run the macro, the image I use in the excel sheet does have a light grey border among the picture.

Is there a difference between running a macro from the editor directly or from a command button?

Bellow you will see my macro, excuse me from the dutch text in it;)

Code:
Sub PDFgenererenCSS()

Dim PdfName As String


If Sheet1.Range("I2") = "" Then


    PdfName = Sheet1.Range("H2").Value & "van" & Sheet1.Range("H3").Value & "-" & Sheet1.Range("C9").Value & "-CSS"
    
    Else


    PdfName = Sheet1.Range("H2").Value & "van" & Sheet1.Range("H3").Value & "-" & Sheet1.Range("C9").Value & "-CSS Rev" & Sheet1.Range("I2").Value
    End If


If Sheet1.Range("H2") = "" Then


    MsgBox "Vul een waarde in bij cel H2"
    Exit Sub
    
    Else
    
If Sheet1.Range("H3") = "" Then


    MsgBox "Vul een waarde in bij cel H3"
    Exit Sub
    
    Else
    
If Sheet1.Range("C9") = "" Then


    MsgBox "Vul een waarde in bij cel C9"
    Exit Sub
    
    Else


If Dir("D:\LWARKEST\Desktop\" & PdfName & ".pdf") <> "" Then


    If Sheet1.Range("q16") = "" Then


    If MsgBox("Het bestand: " & PdfName & ".pdf bestaat al, wilt u deze overschrijven?", vbOKCancel) = vbOK Then
        Sheet2.ExportAsFixedFormat Type:=xlTypePDF, Filename:="D:\LWARKEST\Desktop\" & PdfName & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, From:=1, To:=1, OpenAfterPublish:=True
        MsgBox "uw document is opgeslagen", vbInformation
    End If
    
    Else
    
      If MsgBox("Het bestand: " & PdfName & ".pdf bestaat al, wilt u deze overschrijven?", vbOKCancel) = vbOK Then
        Sheet2.ExportAsFixedFormat Type:=xlTypePDF, Filename:="D:\LWARKEST\Desktop\" & PdfName & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, From:=1, To:=2, OpenAfterPublish:=True
        MsgBox "uw document is opgeslagen", vbInformation
    End If
    
    End If
       
    Else
    
    If Sheet1.Range("q16") = "" Then
    
    Sheet2.ExportAsFixedFormat Type:=xlTypePDF, Filename:="D:\LWARKEST\Desktop\" & PdfName & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, From:=1, To:=1, OpenAfterPublish:=True
    MsgBox "uw document is opgeslagen", vbInformation


    Else
    
    Sheet2.ExportAsFixedFormat Type:=xlTypePDF, Filename:="D:\LWARKEST\Desktop\" & PdfName & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, From:=1, To:=2, OpenAfterPublish:=True
    MsgBox "uw document is opgeslagen", vbInformation
    End If


End If
End If
End If
End If


End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,214,982
Messages
6,122,581
Members
449,089
Latest member
Motoracer88

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