PDA

View Full Version : Solved: Omitting Path in ActiveWorkbook.Saveas



Opv
03-18-2010, 11:41 AM
If no specific path is designated when using "ActiveWorkbook.Saveas," does Excel default to the current location of the existing file being saved?

lucas
03-18-2010, 12:42 PM
I think it defaults to the excel default file location.

In 2003 it's found at tools-Options.........Pick the General tab and it's the 3rd window from the bottom of the dialgog.

lucas
03-18-2010, 12:56 PM
There are several ways to use savas and thisdocument path:

example:


Sub SaveTopath()
Dim DTAddress As String
DTAddress = ActiveWorkbook.Path & "\"
ActiveWorkbook.SaveAs DTAddress & Sheets("Details").Range("R2")
End Sub

Opv
03-18-2010, 04:19 PM
Thanks for the help. I'll give your suggestion a try.

Opv

Opv
03-18-2010, 04:42 PM
The suggested code works like a charm. Thanks.

This exercise has resulted in another question. Is there an alternative to "saveas" so that I can effectively save a copy of the original file, close the newly saved file and at the same time keep the original file in the active window?


There are several ways to use savas and thisdocument path:

example:


Sub SaveTopath()
Dim DTAddress As String
DTAddress = ActiveWorkbook.Path & "\"
ActiveWorkbook.SaveAs DTAddress & Sheets("Details").Range("R2")
End Sub

lucas
03-18-2010, 08:36 PM
The suggested code works like a charm. Thanks.

This exercise has resulted in another question. Is there an alternative to "saveas" so that I can effectively save a copy of the original file, close the newly saved file and at the same time keep the original file in the active window?

Use savecopyas

Sub SaveAsExample()
Dim DTAddress As String
DTAddress = ActiveWorkbook.Path & "\"
ActiveWorkbook.SaveCopyAs DTAddress & Sheets("Details").Range("R2") & ".xls"
End Sub

Opv
03-19-2010, 07:58 AM
Very cool. I wish I had realized the power of VBA years ago. I appreciate the help.

Opv



Use savecopyas

Sub SaveAsExample()
Dim DTAddress As String
DTAddress = ActiveWorkbook.Path & "\"
ActiveWorkbook.SaveCopyAs DTAddress & Sheets("Details").Range("R2") & ".xls"
End Sub