2016 VBA for SaveAs, Print and keep original open

cgull

New Member
Joined
Oct 23, 2017
Messages
2
I have a worksheet for sales orders. I need a code for the following to happen after the sales order has been filled in: save a copy of form (without macros), the completed form printed, the original cleared, the number advanced and the original saved and left open. Can anyone help me. I am new with macros and I am over my head on this. This is what I have so far:

Sub PrintSO()
ActiveSheet.PrintOut
End Sub
Sub NextSO()
Range("N1").Select
ActiveCell.FormulaR1C1 = ActiveCell.FormulaR1C1 + 1
End Sub
Sub SO()
Dim File As Variant

Application.DisplayAlerts = False

File = "C:\Users\***\Documents\***\SO" & Range("M1").Value & Range("N1").Value

ActiveWorkbook.SaveAs File, FileFormat = 52

Application.DisplayAlerts = True

End Sub
Sub Picture3_Click() (This is the button to push to print save)
Call PrintSO
Call SO
Call ClearSO
Call NextSO
End Sub

Thank you in advance for any help.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi & welcome to the board
If it's just the one sheet, try
Code:
Sub SO()
Dim File As Variant
Application.DisplayAlerts = False

File = "C:\Users\***\Documents\***\SO" & Range("M1").Value & Range("N1").Value
ActiveSheet.Copy
ActiveWorkbook.SaveAs File, 51
ActiveWorkbook.Close False
Application.DisplayAlerts = True

End Sub
 
Upvote 0
It shouldn't. Try this, a message box will appear with the file path & name. Is it correct
Code:
Sub SO()
Dim FileNme As Variant
Application.DisplayAlerts = False

FileNme = "C:\Users\***\Documents\***\SO" & Range("M1").Value & Range("N1").Value
MsgBox FileNme
ActiveSheet.Copy
ActiveWorkbook.SaveAs FileNme, 51
ActiveWorkbook.Close False
Application.DisplayAlerts = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,582
Members
449,039
Latest member
Arbind kumar

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