Multiple Sheet Workbook to PDF

ehoots

New Member
Joined
Jul 10, 2017
Messages
4
I'm very new to <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-top-style: initial; border-right-style: initial; border-bottom-style: dotted; border-left-style: initial; border-top-color: initial; border-right-color: initial; border-bottom-color: rgb(0, 0, 0); border-left-color: initial; border-image: initial; cursor: help; color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">VBA</acronym> and am having issues with a project I am working on. I have a workbook that contains 15 sheets with different data types in each. There is a home page with hyperlinks to each sheet. All sheets have a title and link to the home page on the top of the sheet. The goal is to have this workbook converted to PDF. However I do not want the Home page ever included or the title and link on the separate sheets. And not all sheets will always be converted. The idea I was going with was: the user will place and x in the cell next to the pages (on the home page list) they want to include and a for loop will find the sheets without and hide them before hiding the home page and finally converting to pdf. How would this be done? The sheets vary quite a bit and I have been having issues fitting them on PDF pages correctly. Is there an easy way to resolve this?
Here is what is have so far and like I said no experience with <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-top-style: initial; border-right-style: initial; border-bottom-style: dotted; border-left-style: initial; border-top-color: initial; border-right-color: initial; border-bottom-color: rgb(0, 0, 0); border-left-color: initial; border-image: initial; cursor: help; color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">VBA</acronym>: the bold is what is currently failing, its an attempt to take the text in a cell that corresponds to a sheet and then activate that sheet. It does not work.


Private Sub CommandButton1_Click()
Dim i As Integer
Dim page As String
Dim tabs As Integer
Dim WB As Workbook
Dim sheet As Worksheet
Set WB = ActiveWorkbook
tabs = WB.Sheets.Count
For i = 1 To tabs
page = Sheets("HOME").Range("C" & (i + 12)).Text
If Len(Trim(Range("C" & (i + 12))) = 0) Then
Sheets(" 'page' ").Activate
sheet.Visible = xlSheetHidden
End If
Next
Worksheets("HOME").Activate
ActiveSheet.Visible = xlSheetHidden
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,215,455
Messages
6,124,935
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top