+ Reply to Thread
Results 1 to 15 of 15

VBA Range to PDF

  1. #1
    Forum Contributor
    Join Date
    10-28-2010
    Location
    quebec, canada
    MS-Off Ver
    o365
    Posts
    187

    VBA Range to PDF

    Hi,

    I am using excel 2016 (o365), and i used to have a similar formula on another job on excel 2013, but somehow i can't grasp where it fails...

    here's my script

    Please Login or Register  to view this content.
    The red section is highligted in yellow, and i get the error "document not saved"

    Clues?

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: VBA Range to PDF

    Assign the filename to a string variable and take a look at it. Is it valid?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: VBA Range to PDF

    What did your debug.print for the following expression

    Please Login or Register  to view this content.
    evaluate to?

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,257

    Re: VBA Range to PDF

    Like this maybe.

    Please Login or Register  to view this content.
    Last edited by bakerman2; 02-18-2017 at 02:40 AM.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Forum Contributor
    Join Date
    10-28-2010
    Location
    quebec, canada
    MS-Off Ver
    o365
    Posts
    187

    Re: VBA Range to PDF

    If i set the debug print Range to a name instead the code will work, BUT no pdf is created.

  6. #6
    Forum Contributor
    Join Date
    10-28-2010
    Location
    quebec, canada
    MS-Off Ver
    o365
    Posts
    187

    Re: VBA Range to PDF

    Ok filename issue mostly... if i take off the custom naming, and put "test" for example, the pdf will be produce, but with the excel document name, and not my custom name.

  7. #7
    Forum Contributor
    Join Date
    10-28-2010
    Location
    quebec, canada
    MS-Off Ver
    o365
    Posts
    187

    Re: VBA Range to PDF

    i dunno what to do at this point :S

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,257

    Re: VBA Range to PDF

    I guess it all depends on what's in the cells you use to make the name of the pdf-file. You probably use a sign that's not allowed to create a filename.
    Can you give example what a name looks like ?

  9. #9
    Forum Contributor
    Join Date
    10-28-2010
    Location
    quebec, canada
    MS-Off Ver
    o365
    Posts
    187

    Re: VBA Range to PDF

    it's just name of the person, and the date. it will output like

    xatomicx team - John doe - February 2017

    What i'm surprised is that even if i used a fixed name file, it will output as the excel file name anyway, but in pdf.

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: VBA Range to PDF

    Does
    Please Login or Register  to view this content.
    make a difference?

  11. #11
    Forum Contributor
    Join Date
    10-28-2010
    Location
    quebec, canada
    MS-Off Ver
    o365
    Posts
    187

    Re: VBA Range to PDF

    Where would i put that?

    Please Login or Register  to view this content.

  12. #12
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,257

    Re: VBA Range to PDF

    This works perfectly fine for me.

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    10-28-2010
    Location
    quebec, canada
    MS-Off Ver
    o365
    Posts
    187

    Re: VBA Range to PDF

    HTML Code: 
    .Range("A1:K42").ExportAsFixedFormat 0, fp
    Red line is debugger highlighted yellow line when i get the "document not saved"

  14. #14
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,257

    Re: VBA Range to PDF

    This is just not possible so I'm beginning to have serious doubts that o365 supports this method of exporting to Pdf.

  15. #15
    Forum Contributor
    Join Date
    10-28-2010
    Location
    quebec, canada
    MS-Off Ver
    o365
    Posts
    187

    Re: VBA Range to PDF

    now i think about it, I can save as pdf, but pretty sure pdf is not in the export, can made it save as instead of export?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 07-05-2016, 05:40 AM
  2. Replies: 9
    Last Post: 05-19-2016, 06:48 PM
  3. Replies: 0
    Last Post: 05-18-2016, 04:52 PM
  4. [SOLVED] Help! - Copy Range (Sheet1,A10:F50), Paste Range (Sheet 2,A1:F41), Offset Range & Repeat
    By cjtimmer in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-30-2015, 06:27 PM
  5. [SOLVED] Count number of occurances below a range, within a range, and below a range
    By maacmaac in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-15-2013, 11:36 PM
  6. [SOLVED] Query Oracle using range in Excel to return individual records for each cell in range
    By bigwillydier in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-18-2013, 06:37 PM
  7. send to range, popup box to input what the range should be each time/select range
    By lax2734 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2012, 01:37 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1