ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Want to Set the File Save As path (https://www.excelbanter.com/excel-programming/354169-want-set-file-save-path.html)

Brenda

Want to Set the File Save As path
 
In my Visual FoxPro Code, I create an excel spreadsheet but do not save it.
Once in Excel, my client would always want to save the spreadsheet in a
certain folder. I would like to set the folder for the client. Unfortunately,
the following code only seems to work the second time. the first time, it
retains the previously used Save As folder path.

site_id = '10'
cDirectory = rpath + '\Query_Maker\r' +ALLTRIM(site_id)+'\'
RELEASE oexcel
oExcel = CREATEOBJECT('Excel.Application')
oExcel.DefaultFilePath = cDirectory
oExcel.Workbooks.Add
oexcel.Visible = .t.


Any Help would be appreciated.

Brenda

Tom Ogilvy

Want to Set the File Save As path
 
You shouldn't set DefaultFilePath. This is a user selected location and
could screw up there setup.

If you want to save to a specific file

site_id = '10'
cDirectory = rpath + '\Query_Maker\r' +ALLTRIM(site_id)+'\'
RELEASE oexcel
oExcel = CREATEOBJECT('Excel.Application')
oExcel.Workbooks.Add
oexcel.Visible = .t.
' set the default path file and path - this is vba
chDrive cDirectory
chDir cDirectory

In foxpro as I recall it is

Set Default to cdirectory

but I don't know if that would make it operating system wide like chDrive
and chDir

--
Regards,
Tom Ogilvy


"Brenda" wrote in message
...
In my Visual FoxPro Code, I create an excel spreadsheet but do not save

it.
Once in Excel, my client would always want to save the spreadsheet in a
certain folder. I would like to set the folder for the client.

Unfortunately,
the following code only seems to work the second time. the first time, it
retains the previously used Save As folder path.

site_id = '10'
cDirectory = rpath + '\Query_Maker\r' +ALLTRIM(site_id)+'\'
RELEASE oexcel
oExcel = CREATEOBJECT('Excel.Application')
oExcel.DefaultFilePath = cDirectory
oExcel.Workbooks.Add
oexcel.Visible = .t.


Any Help would be appreciated.

Brenda





All times are GMT +1. The time now is 09:06 AM.

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