Outputting reports as PDF

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajalwaysus
    Recognized Expert Contributor
    • Jul 2009
    • 266

    #16
    With just a quick glance, because this is a whole lot of code, I think it is because you are using an "Exit Sub" but the final line in your code indicates this is a Function. Perhaps replacing "Exit Sub" with "Exit Function" will work.

    Let me know if this works,
    -AJ

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #17
      Originally posted by ajalwaysus
      Perhaps replacing "Exit Sub" with "Exit Function" will work.
      It will. Nice catch AJ.

      Comment

      • g diddy
        New Member
        • Sep 2009
        • 54

        #18
        Yes that was the problem there, school boy error by me missing that! thanks for spotting it so quickly!

        I now get the error:

        Code:
        The report name 'MyChoice' you entered in either the property
        sheet or macro is misspelled or refers to a report that doesn't exist.
        Dim MyChoice As String is the variable and it holds the name of the report. I have a few of these variables as there are a few reports. MyReport is the name of the file when it is opened/sent/saved - it has worked with rtf so i've obviously messed up with the new code somewhere. How do you call the variable in the code?

        To give you an idea of what I have for the check box I am testing:

        Code:
        *chunk of code declaring variables etc missed out*
        MyChoice = "Full Special Needs (Students and Invigilators) by Faculty"
        MyReport = "FullSpecialNeeds"
            DoCmd.OpenReport "MyChoice", acViewPreview, , , acHidden
            strFullPath = "C:\MyReport.pdf"
            blRet = ConvertReportToPDF("MyChoice", vbNullString, _
            strFullPath, False, False, 150, "", "", 0, 0, 1
        
        * big chunk of code to do with other things missed out*
        
           .Body = "Find attached Report: " & MyChoice & " for School Code: " & MySchool & vbCrLf & vbCrLf
            Set oAttach = .Attachments.Add("c:\" & MyReport & ".pdf")
        If I can get one working I should hopefully be able to fix the rest myself. The only problem is i'm useless at troubleshooting !!

        Thanks again!!

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32633

          #19
          In lines #4 & #6 you use the string "MyChoice" instead of the variable MyChoice. Have fun.

          Comment

          • g diddy
            New Member
            • Sep 2009
            • 54

            #20
            I love you

            Thank you NeoPa and Ajalwaysus for all your help!!
            I really appreciate it. Thank you :D

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32633

              #21
              Well, it was mainly AJ's knowledge of the PDF stuff that did the trick, but always glad to see a happy camper anyway :)

              Comment

              • ajalwaysus
                Recognized Expert Contributor
                • Jul 2009
                • 266

                #22
                It's an all around effort. Glad it works. =)

                -AJ

                Comment

                • blah DeBlah
                  New Member
                  • Jan 2012
                  • 9

                  #23
                  gawd the hoops access and adobe make you go through to do what should be simple. complete failure on their part.

                  Comment

                  Working...