Create button to print a separate workbook without opening.

EnviroBob

New Member
Joined
Dec 12, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Excel macro novice here.
I have a Customer info workbook my employees need access to. see pic. On the "form" column, the "Y" indicates a specific printable form is needed for their job that is in another workbook that I don't want them to have access to. I would like to make the "Y" a button they can press and print the form without opening the form workbook. I've read that I may need to convert the forms to pdf. Any help would be appreciated. Thanks for your time.
 

Attachments

  • Screenshot 2023-12-12 111737.png
    Screenshot 2023-12-12 111737.png
    73.3 KB · Views: 13

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
This code would be a start.

VBA Code:
Sub PrintHiddenWorkbook()
    Dim wb As Workbook
    
    ' Open the workbook without displaying it
    Set wb = Workbooks.Open("C:\Path\To\Your\File.xlsx", False, True) ' Replace with your file path
    
    ' Print the specific sheet
    wb.Sheets("SheetName").PrintOut ' Replace "SheetName" with the name of your sheet
    
    ' Close the workbook without saving changes and without prompting
    wb.Close SaveChanges:=False
End Sub
 
Upvote 0
Solution
This code would be a start.

VBA Code:
Sub PrintHiddenWorkbook()
    Dim wb As Workbook
   
    ' Open the workbook without displaying it
    Set wb = Workbooks.Open("C:\Path\To\Your\File.xlsx", False, True) ' Replace with your file path
   
    ' Print the specific sheet
    wb.Sheets("SheetName").PrintOut ' Replace "SheetName" with the name of your sheet
   
    ' Close the workbook without saving changes and without prompting
    wb.Close SaveChanges:=False
End Sub
Brilliant! Thank you! I've got the rest figured out. Cold beverage of your choice to you, sir.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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