Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default saving a file

Is there a reason why the file gets saved into My Documents folder instead
of a specific location on D drive? I ran the line carefully and it looks
fine but it does not get saved in the expected folder. The ChDir appears to
be on strike!

Thank you for your help

Function saveFile(ByVal thisDir As String, ByVal thisFile As String)
Dim isFileExist As Boolean
Dim fullPath As String
fullPath = thisDir & thisFile
isFileExist = fileInExistence(thisDir, thisFile)
If isFileExist Then
Kill thisDir & thisFile
ChDir thisDir
ActiveWorkbook.SaveAs fileName:=thisFile,
FileFormat:=xlWorkbookNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, CreateBackup:=False
Else
ChDir thisDir
ActiveWorkbook.SaveAs fileName:=thisFile, FileFormat:=xlNormal,
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
CreateBackup:=False
End If
End Function


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default saving a file

chdir sets the default directory for the specified drive, but it doesn't
change the default drive.

Function saveFile(ByVal thisDir As String, ByVal thisFile As String)
Dim isFileExist As Boolean
Dim fullPath As String
fullPath = thisDir & thisFile
isFileExist = fileInExistence(thisDir, thisFile)
If isFileExist Then
Kill thisDir & thisFile
ChDrive thisDir
ChDir thisDir
ActiveWorkbook.SaveAs fileName:=thisFile,
FileFormat:=xlWorkbookNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, CreateBackup:=False
Else
ChDrive thisDir
ChDir thisDir
ActiveWorkbook.SaveAs fileName:=thisFile, FileFormat:=xlNormal,
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
CreateBackup:=False
End If
End Function

--
Regards,
Tom Ogilvy


"LearningVBA" wrote in message
...
Is there a reason why the file gets saved into My Documents folder instead
of a specific location on D drive? I ran the line carefully and it looks
fine but it does not get saved in the expected folder. The ChDir appears
to be on strike!

Thank you for your help

Function saveFile(ByVal thisDir As String, ByVal thisFile As String)
Dim isFileExist As Boolean
Dim fullPath As String
fullPath = thisDir & thisFile
isFileExist = fileInExistence(thisDir, thisFile)
If isFileExist Then
Kill thisDir & thisFile
ChDir thisDir
ActiveWorkbook.SaveAs fileName:=thisFile,
FileFormat:=xlWorkbookNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, CreateBackup:=False
Else
ChDir thisDir
ActiveWorkbook.SaveAs fileName:=thisFile, FileFormat:=xlNormal,
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
CreateBackup:=False
End If
End Function



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving Excel 2007 file in 2003 creates very large file Jon Pearce Excel Discussion (Misc queries) 2 July 16th 09 07:20 PM
Saving worksheet in new file with date AND cell value as file name michaelberrier Excel Discussion (Misc queries) 4 May 26th 06 08:05 PM
Saving multi-tab excel file created from comma delimited text file Marcus Aurelius Excel Programming 2 December 19th 05 05:16 PM
How do I stop Excel 2000 from saving file history from file that . Cathy Excel Discussion (Misc queries) 0 March 29th 05 03:27 PM
saving an excel file as an ASCII text file without delimiters Sewellst Excel Programming 4 January 7th 05 01:41 PM


All times are GMT +1. The time now is 01:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"