Print - Print Preview - Close

MRK_Toledo

New Member
Joined
Sep 2, 2006
Messages
34
I have a workbook that opens without any command bars or menu bars, making it look like a standalone app.

I have the code in place to restore everything on exit, and that works good.

I would like to know if there is a way that I can make 3 different buttons:

Print
Print Preview
Close (closes excel completely)

I would like for these to be assigned to a cell.

Is this possible?
 

Excel Facts

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

do you have code for these three events ?
(if not you can use the macro-recorder as a start)
what do you mean by "assigned" to a cell ?

How to create a button and assign a macro to it:
one way

If you don't already have the "Forms" toolbar active, click on Tools>Customize>Toolbars and check "Forms". The toolbar will appear on your screen; drag it down to the bottom of your screen to anchor it.

Click on the Button icon, and drag out a button on the screen. When you release the left mouse button, an "Assign Macro" dialogue box will appear. Highlight whatever macro you want, and click OK. The macro will now be assigned to that button.


kind regards,
Erik
 
Upvote 0
Thanks for the Info....

I think this will work....I don't need to have the code be attached to a cell, I didn't know that you could create a button on use that....that will work much better.

I do have a little problem though.....I do not have any of the MACRO commands in the TOOLS menu, and I can't figure out where they went.

I even used the CUSTOMIZE feature - and the spot where it would be listed, has a check box next to it, but no text.....very weird.

Until I get the MACRO functions back - I'm kinda stuck.
 
Upvote 0
Nope, that didn't work.

Here is a good one....

I have this code in my ThisWorkbook:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Mypath = "C:\Junk\"
MyFileName = Sheets("start").Range("k13").Text
MyFileName2 = Sheets("start").Range("d21").Text
MyFileName3 = Sheets("start").Range("d25").Text
On Error Resume Next
ActiveWorkbook.SaveAs Filename:=Mypath & MyFileName & MyFileName2 & MyFileName3 & ".xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
ThisWorkbook.Saved = True

What happens here is - when the user hits the 'x' in the top right corner of the window to close excel, it looks for changes, if changes are present, then it saves the file with a specific file name. If no changes are present, then it just closes, and does not save anything.

I am trying to make a button to do this same thing.

Here is what I have tried so far....

Code:
ActiveWorkbook.Close savechanges:=False 'true ???
             --will close the active workbook

also tried this one...

Code:
Workbooks("mywkbk.xls").Close savechanges:=False 'true ???
             --will close mywkbk.xls

and I tried this one too....

Code:
ThisWorkbook.Close savechanges:=False 'true ???
             --will close the workbook that holds the code that's running.

There is some kind of conflict going on here and I'm not sure what it is.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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