Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Saving Files

My macro used to save the file to the directory that Excel was executed from.
Now my Macro only saves to the root of My Documents. No matter what
directory I am in the program thinks the CurDir in My Document

MySavePath = CurDir (This is the only reference to CurDir in the Module)

'Save Excel Workbook
ActiveWorkbook.Save

Sheets("AP4301").Select
AcctMth = Str(Month(Range("AcctgPeriod").Value))
AcctYear = Str(Year(Range("AcctgPeriod").Value))

'Save Import File in Text Format
ActiveWorkbook.SaveAs Filename:= _
MySavePath & "\AP4301OKCityJIBImport" & Trim(AcctMth) & Trim(AcctYear)
& ".txt", _
FileFormat:=xlTextWindows, CreateBackup:=False

I do not want to hard code the directory path in the file since the directory
changes. Were there update to CurDir function in the patches that Micro Soft
send out? Is there a way, to select a directory like when I use th e
FileDialog

With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Add "Text files", "*.den"

This is fustrating not knowing where the file will be save

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200703/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Saving Files

There is a folder picker dialog that you could use:
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Title = "Please select folder in which to save file"
If .Show = False Then Exit Sub 'User Clicked Cancel
MySaveFolder = .SelectedItems(1)
End With
ActiveWorkbook.SaveAs Filename:= MySavePath & _
"\AP4301OKCityJIBImport" & Trim(AcctMth) &
Trim(AcctYear) & ".txt", _
FileFormat:=xlTextWindows, CreateBackup:=False

--
Charles Chickering

"A good example is twice the value of good advice."


"Fredriksson via OfficeKB.com" wrote:

My macro used to save the file to the directory that Excel was executed from.
Now my Macro only saves to the root of My Documents. No matter what
directory I am in the program thinks the CurDir in My Document

MySavePath = CurDir (This is the only reference to CurDir in the Module)

'Save Excel Workbook
ActiveWorkbook.Save

Sheets("AP4301").Select
AcctMth = Str(Month(Range("AcctgPeriod").Value))
AcctYear = Str(Year(Range("AcctgPeriod").Value))

'Save Import File in Text Format
ActiveWorkbook.SaveAs Filename:= _
MySavePath & "\AP4301OKCityJIBImport" & Trim(AcctMth) & Trim(AcctYear)
& ".txt", _
FileFormat:=xlTextWindows, CreateBackup:=False

I do not want to hard code the directory path in the file since the directory
changes. Were there update to CurDir function in the patches that Micro Soft
send out? Is there a way, to select a directory like when I use th e
FileDialog

With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Add "Text files", "*.den"

This is fustrating not knowing where the file will be save

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200703/1


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Saving Files

Thank you very much. I will try this.

Charles Chickering wrote:
There is a folder picker dialog that you could use:
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Title = "Please select folder in which to save file"
If .Show = False Then Exit Sub 'User Clicked Cancel
MySaveFolder = .SelectedItems(1)
End With
ActiveWorkbook.SaveAs Filename:= MySavePath & _
"\AP4301OKCityJIBImport" & Trim(AcctMth) &
Trim(AcctYear) & ".txt", _
FileFormat:=xlTextWindows, CreateBackup:=False

My macro used to save the file to the directory that Excel was executed from.
Now my Macro only saves to the root of My Documents. No matter what

[quoted text clipped - 25 lines]

This is fustrating not knowing where the file will be save


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200703/1

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 files colleen Excel Discussion (Misc queries) 1 March 2nd 07 05:52 AM
Closing files and saving files dan Excel Worksheet Functions 0 August 15th 06 04:07 AM
Saving Files Jez[_7_] Excel Programming 3 April 4th 06 06:11 PM
saving files Marlis Excel Discussion (Misc queries) 0 August 17th 05 05:56 AM
Saving csv files Steve Excel Discussion (Misc queries) 2 July 20th 05 06:43 PM


All times are GMT +1. The time now is 11:51 PM.

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

About Us

"It's about Microsoft Excel"