command button to save and print

Muascott

New Member
Joined
Oct 27, 2005
Messages
38
hello all,
I am trying to write a macro for a button to do these tasks
1. save as workbook in a location say C:\My Documents\Msr's for numbers action.
2. use a range on the workbook for the title of the saved workbook say
"D4"
3. saved workbook to have prefix text of MSR F00xxx then Followed by the text in range D4
4. print the workbook
5. automatically close excel.

any ideas?

thanks
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Maybe something like this (in a standard module):

Code:
    With ActiveWorkbook
        .SaveAs "C:\My Documents\Msr's\MSR F00" & Range("D4").Value & ".xls"
        .PrintOut
        .Close 0
    End With
    Application.Quit

Hope that helps!
 
Upvote 0
how do i get it to just print the active sheet and not the workbook?

also the button closes the workbook but not excel can that be done?



thanks
scott
 
Upvote 0
how do i get it to just print and save the active sheet and not the workbook?

also the button closes the workbook but not excel can that be done?



thanks
scott
 
Upvote 0
You did say save the workbook and print the workbook in your original post. However, this should do the trick:

Code:
With Activesheet 
        .SaveAs "C:\My Documents\Msr's\MSR F00" & Range("D4").Value & ".xls" 
        .PrintOut 
    End With 
    Application.Quit

Application.Quit should close Excel. If you want to ignore any dialogs that might pop up during this operation, you could set Application.DisplayAlerts to False.

HTH
 
Upvote 0

Forum statistics

Threads
1,207,255
Messages
6,077,313
Members
446,278
Latest member
hoangquan2310

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