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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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
 
Upvote 0
Put this line at the end of your procedure:

Application.Dialogs(xlDialogSaveAs).Show
 
Upvote 0
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
 
Upvote 0
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)
 
Upvote 0
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
 
Upvote 0
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:
 
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,367
Members
449,080
Latest member
Armadillos

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