VBA Tweak

diatex

Board Regular
Joined
Jan 16, 2004
Messages
96
Hello

I am using this snippet of vba to print two copies, would it be possible to amend this so the "save as" box also appeared after clicking the command button.

Sub PrintAndNumberInvoice()
Range("A1").Value = Range("A1").Value + 1
ActiveWindow.SelectedSheets.PrintOut Copies:=2, Collate:=True
End Sub

Thanks

Diatex
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,460
The easy way to is put in a input box for the user to type the name required as follows:

FileName1 = InputBox("Please input filename", "Filename")
ChDir "c:\"
ActiveWorkbook.SaveAs Filename:="C:\" & FileName1, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
 

CraigM

Active Member
Joined
Feb 27, 2003
Messages
320
Put this line at the end of your procedure:

Application.Dialogs(xlDialogSaveAs).Show
 

diatex

Board Regular
Joined
Jan 16, 2004
Messages
96
Thanks for the quick response CraigM & tactps, both fit the bill.

I have been playing around trying to enter the full file path in tactps vba, so i can save to a folder called downloads on c:\ but i must be missing something somewhere. Any chance of an ammendment then i can go to bed without my brain working overtime all night
thanks again men
Diatex
 

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,460

ADVERTISEMENT

FileName1 = InputBox("Please input filename", "Filename")
ChDir "c:\downloads\"
ActiveWorkbook.SaveAs Filename:="C:\downloads\" & FileName1, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

This will automatically save it in "downloads" without having to type the full path.

Otherwise, get rid of the "c:\" statement in the savas line, and just leave "FileName1". Then type full path (untested but should work)
 

diatex

Board Regular
Joined
Jan 16, 2004
Messages
96
Thanks tactps

never noticed the SaveAs Filename:="C:\ on the third line obviously looking too hard. Now i can go to bed

goodnight or is it good morning for you

Thanks
diatex
 

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,460
Also change line 2 (will work faster).

Sleep well and no dreaming of macros!!!!

Noon here - {so maybe time for me to have a sleep too!} :LOL:
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,095
Messages
5,768,054
Members
425,451
Latest member
JohnBrooksBiddle

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
Top