ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SaveCopyAs method (https://www.excelbanter.com/excel-programming/291493-savecopyas-method.html)

Lee

SaveCopyAs method
 
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"



Bob Phillips[_6_]

SaveCopyAs method
 
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)

"Lee" wrote in message
...
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

SaveCopyAs method
 
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.
-----Original Message-----
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)

"Lee" wrote in

message
...
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"




.


Tom Ogilvy

SaveCopyAs method
 
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"

--
Regards,
Tom Ogilvy


"Lee" wrote in message
...
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"





Bob Phillips[_6_]

SaveCopyAs method
 
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)

"Lee" wrote in message
...
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.
-----Original Message-----
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)

"Lee" wrote in

message
...
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"




.





All times are GMT +1. The time now is 09:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com