+ Reply to Thread
Results 1 to 12 of 12

Create button to Save specific page ranges from each worksheet in the workbook

  1. #1
    Registered User
    Join Date
    10-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    67

    Question Create button to Save specific page ranges from each worksheet in the workbook

    I have an excel workbook containing about 4 worksheets.
    The second worksheet has all the inputs I give and the outputs that I require.
    The fourth worksheet has graphs.
    All the calculations happen on other worksheets
    I need to create a command button, which when clicked saves a certain pages of each worksheet as a PDF file.
    Say, I need the the 1st page of Worksheet 1, 1st page of Worksheet 2 and 1st and 2nd pages of Worksheet 4
    (all pages laid-out as A4 using "Page layout > Size > A4 "and viewed as "View > Page Layout")
    Is it possible to get a VB code to save those particular pages as a single PDF document.
    Also the PDF document must derive its file name from two different cells in Worksheet 1

    The same query is also posted at
    http://www.mrexcel.com/forum/excel-q...-workbook.html
    Last edited by projectatpel; 12-25-2013 at 06:41 AM. Reason: To provide link back

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Create button to Save specific page ranges from each worksheet in the workbook

    Hi, projectatpel,

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).


    http://www.mrexcel.com/forum/excel-q...-workbook.html

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    10-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Create button to Save specific page ranges from each worksheet in the workbook

    Sorry, I din't know that wee have to link back even from other sites! And thanx for intimating me.
    I have added the link back in my description.
    Quote Originally Posted by HaHoBe View Post
    Hi, projectatpel,

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).


    http://www.mrexcel.com/forum/excel-q...-workbook.html

    Ciao,
    Holger

  4. #4
    Registered User
    Join Date
    10-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Create button to Save specific page ranges from each worksheet in the workbook

    I have worked out a code, to add to a command button, but it seems to have some syntax error. If anyone can help

    Please Login or Register  to view this content.

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Create button to Save specific page ranges from each worksheet in the workbook

    Hi projectatpel,

    I believe your problem to be in the multiple range designation because multiple ranges have multiple values (normally) - are they merged ranges? If so, then you need only designate the first cell??
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  6. #6
    Registered User
    Join Date
    10-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Create button to Save specific page ranges from each worksheet in the workbook

    Dear xladept,

    Yes, they are merged cells, and I have tried designating only the first cell, but that doesn't seem to work either!
    If you could actually try it out, to check the error, it would be great.

    These are the errors that I am getting

    When the button is clicked , to run it:
    Run time Error.jpg

    While debugging, this is the error showing up!
    Run time Error 2.jpg

    Quote Originally Posted by xladept View Post
    Hi projectatpel,

    I believe your problem to be in the multiple range designation because multiple ranges have multiple values (normally) - are they merged ranges? If so, then you need only designate the first cell??

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Create button to Save specific page ranges from each worksheet in the workbook

    Hi projectatpel,

    Try:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    10-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Create button to Save specific page ranges from each worksheet in the workbook

    Doesn't work yet! the same run time error still shows up!

    Quote Originally Posted by xladept View Post
    Hi projectatpel,

    Try:

    Please Login or Register  to view this content.

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Create button to Save specific page ranges from each worksheet in the workbook

    I wonder whether the filename is correct?

  10. #10
    Registered User
    Join Date
    10-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Create button to Save specific page ranges from each worksheet in the workbook

    Please Login or Register  to view this content.
    This was the original code i found online. I edited the format to match as PDF and it did work when i tried on a sample excel sheet

    But when i do the same on my project, it gives errors!

  11. #11
    Registered User
    Join Date
    10-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Create button to Save specific page ranges from each worksheet in the workbook

    This is the latest code I've tried, but there seems to be some problem with the syntax in referring to file name. Thus the resulting file name is erroneous.

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    10-18-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Create button to Save specific page ranges from each worksheet in the workbook

    Aah finally, after hours of tweaking and sleepless nights, here it occurs. Its so simple, that I feel embarrassed of not cracking it earlier

    Please Login or Register  to view this content.
    Report and Graphs are sheet names

    The final file in PDF format is save in folder D:\Test
    Consider the value in cell D5 of sheet Report be 1234423, then
    File is named as "Calculation ID= 1234423 on [Current Date] at [Current Time] AM/PM.pdf"

+ 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. [SOLVED] Create button to save cell data to workbook header
    By tailz in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 08-28-2013, 07:06 AM
  2. Create New workbook and save it in specific folder for each row inserted.
    By yrk2k8 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2013, 02:15 AM
  3. Comman Button to Save Worksheet as Workbook
    By tmstreet in forum Excel General
    Replies: 2
    Last Post: 07-17-2006, 12:50 PM
  4. [SOLVED] [SOLVED] Create a button to Save As the workbook
    By Helen in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-24-2005, 02:25 AM
  5. Replies: 2
    Last Post: 07-06-2005, 02:05 PM

Tags for this Thread

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