+ Reply to Thread
Results 1 to 15 of 15

VBA is not printing to PDF correctly

  1. #1
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    85

    VBA is not printing to PDF correctly

    Here is my code

    VBA is not printing the correct area instead it is printing C3:X212. (The correct area is "$c$3:$AA$212")

    Can someone help?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: VBA is not printing to PDF correctly

    Can your columns C:AA all fit on one page width? You may have to play with the page margins, zoom to fit, and\or font sizes to get it to fit.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    85

    Re: VBA is not printing to PDF correctly

    Quote Originally Posted by AlphaFrog View Post
    Can your columns C:AA all fit on one page width? You may have to play with the page margins, zoom to fit, and\or font sizes to get it to fit.
    I set all margins to zero already

    When I looked at the pages to be printed it all seems fine but when it prints to PDF it is out of whack

    Here are the pics

    http://i.hizliresim.com/5VaM7z.jpg

    http://i.hizliresim.com/y46L5k.jpg

    http://i.hizliresim.com/2Z68Z2.jpg
    Last edited by misterno; 06-22-2016 at 04:22 PM.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA is not printing to PDF correctly

    Maybe a little reorganizing:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: VBA is not printing to PDF correctly

    How is it different than the print preview?

    To get the right page setup for zoom to fit, record a Print but then cancel the actual print, stop recording, and then view the code.

  6. #6
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    85

    Re: VBA is not printing to PDF correctly

    Quote Originally Posted by JBeaucaire View Post
    Maybe a little reorganizing:
    Please Login or Register  to view this content.
    I ran this 3 times, but it gives me blank pages

  7. #7
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    85

    Re: VBA is not printing to PDF correctly

    Quote Originally Posted by Kenneth Hobson View Post
    How is it different than the print preview?

    To get the right page setup for zoom to fit, record a Print but then cancel the actual print, stop recording, and then view the code.
    Print preview has the whole area covered whereas the printed PDF is cut off on X column instead of AA

    I just saw your recommendation, let me try

    EDIT: Here is the code it recorded

    Please Login or Register  to view this content.
    So how to incorporate this into my VBA?
    Last edited by misterno; 06-22-2016 at 04:44 PM.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA is not printing to PDF correctly

    Replace the last line of the macro I suggested with that snippet above instead.

  9. #9
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    85

    Re: VBA is not printing to PDF correctly

    Quote Originally Posted by JBeaucaire View Post
    Replace the last line of the macro I suggested with that snippet above instead.
    I did but the last paragraph reds out so it does not work

    Please Login or Register  to view this content.
    But if I do this

    Please Login or Register  to view this content.
    then it just prints and of course I want to save it as PDF
    Last edited by misterno; 06-22-2016 at 05:08 PM.

  10. #10
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: VBA is not printing to PDF correctly

    Printto, well prints to your printer. What you want is to export to pdf. You got the PrintTo from recording a macro and printing I guess. I said to cancel printing. You can see the many options set when I set it to Fit All. I doubt that you need all of the options set.

    Another area of confusion is the folder name versus the file name. See my comments. I am not sure which is correct.

    I have not tested this since I don't have your worksheets.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    85

    Re: VBA is not printing to PDF correctly

    Quote Originally Posted by Kenneth Hobson View Post
    Printto, well prints to your printer. What you want is to export to pdf. You got the PrintTo from recording a macro and printing I guess. I said to cancel printing. You can see the many options set when I set it to Fit All. I doubt that you need all of the options set.

    Another area of confusion is the folder name versus the file name. See my comments. I am not sure which is correct.

    I have not tested this since I don't have your worksheets.
    Please Login or Register  to view this content.
    great now I am getting this

    http://i.hizliresim.com/ZdXd1o.jpg

    EDIT: restarted the pc and now it is working

    I need to play around with the margins to make it better though

    Can you tell me what made it work this time?

    Also I need to insert 2 charts to my PDF located in "New England Balances" tab.

    Chart1 and Chart3 are the names and they are located at the right hand side.

    How to insert these to my PDF in a seperate page?
    Last edited by misterno; 06-22-2016 at 05:43 PM.

  12. #12
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: VBA is not printing to PDF correctly

    Order of PDF pages is governed by the sheet index order. As such, try to do this manually first.

    Insert a worksheet for each chart. Set each sheet's print range which encloses the chart(s). Group select the worksheets in consecutive order. Look at Print Preview. Then try a File > SaveAs > PDF.

    IF that works, we can make a macro to do it.

    If not, things get more complex. Another method would be needed which might require Acrobat (not the reader) or a third party program. One would export each range and chart as a picture file and then merge the picture files and Save to PDF.

    If the manual method works, workup a short example file with obfuscated data and attach the file.

  13. #13
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    85

    Re: VBA is not printing to PDF correctly

    Kenneth

    Here is the code but it is not working. It is just printing the sheets but not the chart. Can you help?

    (I am trying your recommendation now)

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    85

    Re: VBA is not printing to PDF correctly

    Here is the code you suggested

    So I inserted a line for the chart are (highlighted) but it is not printing at all not even the sheets itself

    Please Login or Register  to view this content.
    Last edited by misterno; 06-23-2016 at 12:00 PM.

  15. #15
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    85

    Re: VBA is not printing to PDF correctly

    nmxdvxcvcvcv

+ 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. Watermark not printing correctly
    By Smally in forum Word Formatting & General
    Replies: 10
    Last Post: 09-04-2014, 10:59 AM
  2. Printing - FitToPagesWide doesn't scale correctly
    By swoop99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2013, 08:09 AM
  3. [SOLVED] Excel Not Printing Correctly
    By thong127 in forum Excel General
    Replies: 2
    Last Post: 01-10-2012, 05:16 PM
  4. Excel 2007 : Graphs not printing correctly
    By snapyol in forum Excel General
    Replies: 11
    Last Post: 01-06-2012, 10:09 AM
  5. [SOLVED] comments at end of sheet are not printing correctly
    By TreebeardEnt in forum Excel General
    Replies: 0
    Last Post: 06-06-2006, 07:25 PM
  6. AutoCAD text not printing correctly in Excel
    By Michael in forum Excel General
    Replies: 0
    Last Post: 01-30-2006, 04:10 PM
  7. [SOLVED] spread sheet not printing correctly
    By Beebs in forum Excel General
    Replies: 4
    Last Post: 09-21-2005, 09:05 PM

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