Save, then close

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
I have code now to save and copy a file based on info on my form.
It stays open as well as opens


Sub Print_And_Save()
'
' Print_And_Save Macro
' Prints Proposal, saves proposal, then saves as to Completed Proposals folder.
ActiveWorkbook.Save
Path = "C:\WINDOWS\Personal\Completed Proposals\"
Path2 = "C:\WINDOWS\Personal\Surface Systems\"
ActiveWorkbook.SaveAs Filename:= _
Path & "Proposal" & _
Str(Application.Range("N2").Value), FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Range("F2").Select
Workbooks.Open Filename:=Path2 & "Proposal for XL.xls"
End Sub


What do I need to do (and where) to close the workbook I just created? I really want to Save As and Close!
I want to leave the "Proposal for XL" file open ready do work in.

Thank You,
Michael
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

martinee

Well-known Member
Joined
Nov 4, 2003
Messages
960
I'm not sure, but would:

ThisWorkbook.Close

Work if you put it just before the end sub?
 

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
I'll try, but I don't think so because I just opened "Proposal for XL"??

Michael
 

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
Is there code to SaveAs and Close all at once?? :oops:

Thank You,
Michael
 

martinee

Well-known Member
Joined
Nov 4, 2003
Messages
960

ADVERTISEMENT

When you reference "ThisWorkbook", it will always refer to the workbook containing the code. I'm assuming (since you just opened it) that "Proposal for XL" is not the file containing this code. Hopefully it works, but if not, post back and let us know. HTH.
 

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
Thank You for resonding so quickly!

Actually, "Proposal for XL" is where I have the code. I have a button at the top which creates the new file based on it.

Michael
 

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219

ADVERTISEMENT

I am not sure where to sneek it in?? Any ideas out there?

:rolleyes:

Michael
 

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
This one has me totally confused? I don't know where to close the one form and open the other?

Michael :x
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Michael,

Your initial question was
What do I need to do (and where) to close the workbook I just created? I really want to Save As and Close!
If you create a workbook (saveas) as a matter of fact it becomes the activeworkbook

So the line after SaveAs ... you need
ActiveWorkbook.Close

does this help?
Erik
 

Forum statistics

Threads
1,148,220
Messages
5,745,456
Members
423,952
Latest member
EduardoM

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