[VBA excel 2007] Probleem met het exporteren naar pdf

Pagina: 1
Acties:

Acties:
  • 0 Henk 'm!

  • Dorgaldir
  • Registratie: September 2009
  • Laatst online: 10-04 22:52

Dorgaldir

Creature of the web

Topicstarter
Hoi,

ik heb een macro die een bepaalde excel range (A1:N129) exporteert naar pdf en dan automatisch als attachment in een mail hangt bij outlook en emailadres invult zodat ik enkel nog op verzenden moet klikken.

Om dit te laten werken heb ik wel eerst een plugin moeten installeren die SaveAsPdf.exe noemt van Microsoft Corporation.

Sinds twee dagen geeft mijn macro een foute pdf, de tekst die gewoon in de cellen staat word goed geexporteerd maar grafieken en tekeningen enzo worden uitvergroot en springen naar pagina's waar ze niet horen.

Ik heb niets gewijzigd aan deze code en bij mijn weten ook niets aan de worksheet of instellingen van excel.

Ik gebruik hier drie macro's voor
1 verzamelt de variabelen, stelt de mail op en roept de 2 andere macro's aan
2 maakt de pdf
3 opent outlook, vult email in en hangt de pdf als attachment

Aan 3 is niets mis dus die ga ik wegens niet relevant niet plaatsen.
1 is bij mijn weten ook geheel in orde maar zo zou 2 ook moeten zijn, dus deze twee toon ik even.

macro 1 verzamelen en aanroepen
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Sub EmailPdf()
'
' EmailPdf Macro
' Email de factuur als pdf door
'
' Sneltoets: CTRL+SHIFT+E
'

Dim FileName As String
Dim Mail As String
Mail = Sheets("OFFERTE").Range("B5").Value

If ActiveWindow.SelectedSheets.Count > 1 Then
    MsgBox "There is more then one sheet selected," & vbNewLine & _
        "ungroup the sheets and try the macro again"
Else
    'Call the function with the correct arguments


    'For a fixed range use this line
    'FileName = RDB_Create_PDF(Range("A1:O129"), "", True, False)

    'For the selection use this line
    'FileName = RDB_Create_PDF(Selection, "", True, True)

    'For a fixed file name and overwrite it each time you run the macro use
    FileName = RDB_Create_PDF(Range("A1:N129"), "C:\Documents and Settings\XP\Mijn documenten\OFFERTE PDF\OfferteVerstuur.pdf", True, False)

    If FileName <> "" Then
        RDB_Mail_PDF_Outlook FileName, Mail, "Uw offerte", _
                        "Beste" _
                        & vbNewLine _
                       
                        & vbNewLine _
                        & vbNewLine & "Inmiddels verblijven wij met beleefde groeten," , False
    
    Else
        MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
                "Microsoft Add-in is not installed" & vbNewLine & _
                "You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
                "The path to Save the file in arg 2 is not correct" & vbNewLine & _
                "You didn't want to overwrite the existing PDF if it exist"
    End If
End If
End Sub


marco 2 exporteren naar pdf
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Function RDB_Create_PDF(Myvar As Object, FixedFilePathName As String, _
                        OverwriteIfFileExist As Boolean, OpenPDFAfterPublish As Boolean) As String
    Dim FileFormatstr As String
    Dim Fname As Variant

    'Test If the Microsoft Add-in is installed
    If Dir(Environ("commonprogramfiles") & "\Microsoft Shared\OFFICE" _
         & Format(Val(Application.Version), "00") & "\EXP_PDF.DLL") <> "" Then

        If FixedFilePathName = "" Then
            'Open the GetSaveAsFilename dialog to enter a file name for the pdf
            FileFormatstr = "PDF Files (*.pdf), *.pdf"
            Fname = Application.GetSaveAsFilename("", filefilter:=FileFormatstr, _
                                                  Title:="Create PDF")

            'If you cancel this dialog Exit the function
            If Fname = False Then Exit Function
        Else
            Fname = FixedFilePathName
        End If

        'If OverwriteIfFileExist = False we test if the PDF
        'already exist in the folder and Exit the function if that is True
        If OverwriteIfFileExist = False Then
            If Dir(Fname) <> "" Then Exit Function
        End If

        'Now the file name is correct we Publish to PDF
        On Error Resume Next
        Myvar.ExportAsFixedFormat _
                Type:=xlTypePDF, _
                FileName:=Fname, _
                Quality:=xlQualityStandard, _
                IncludeDocProperties:=True, _
                IgnorePrintAreas:=False, _
                OpenAfterPublish:=OpenPDFAfterPublish
        On Error GoTo 0

        'If Publish is Ok the function will return the file name
        If Dir(Fname) <> "" Then RDB_Create_PDF = Fname
    End If
End Function


Ik heb me al moe gezocht naar een oplossing maar vind er geen, iemand een idee of het aan de macro's ligt of aan een instelling ofzo want ik weet het niet meer. 8)7

[ Voor 15% gewijzigd door Dorgaldir op 30-10-2009 11:00 ]

Just me


Acties:
  • 0 Henk 'm!

  • Dorgaldir
  • Registratie: September 2009
  • Laatst online: 10-04 22:52

Dorgaldir

Creature of the web

Topicstarter
Laat maar, ik heb dan uiteindelijk toch de oplossing gevonden.
Hier kan je de oplossing vinden
http://forums.techarena.in/office-update-service/1171873.htm

Just me