SaveCopyAs method

  • Thread starter Thread starter Lee
  • Start date Start date
L

Lee

I am trying to save a copy of a workbook with name and
save it in the same directory as the current workbook. My
problem is that Excel is saving it in the default
directory, My Documents. I know in Access, I would use
application.currentproject.path, but this doesn't seem to
be an option in Excel.

Here is the code I have so far:

Dim strClient As String
strClient = Application.InputBox("Enter client name")
ActiveWorkbook.SaveCopyAs strClient & " " & "Raw
Sample.xls"
 
Lee,

add the path to the command

ActiveWorkbook.SaveCopyAs "C:\myExcel\" & strClient & " " & "Raw Sample.xls"
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Thanks for the reply. However, I should have added that
the path will not always be the same. The file will be
saved to a LAN directory folder that will vary from
project to project. That's why I didn't want to hard code
the path.
 
Dim strClient As String
Dim sPath as Path
sPath = ActiveWorkbook.Path
if right(sPath) <> "\" then sPath = sPath & "\"
strClient = Application.InputBox("Enter client name")
ActiveWorkbook.SaveCopyAs sPath & _
Trim(strClient) & " Raw Sample.xls"
 
Lee,

It doesn't have to be hard-coded. I was juts trying to show that you could
pre-pend it. Somewhere you have to determine what that path is, so you can
save that to a variable and use that.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top