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 Excel File in Current Directory NOT My Documents

I am having two issue with the code below.

The Excel wookbook that executes this code is called JIBUpload-OKCity.xls.
When code executes to the text file it changes the name of the sheet.

The results I would like is that I would like the files to be save in the
current directory not in My Documents. At the end of executing this Macro, I
would like the user to be back where they stared with JIBUpload-OKCity.xls
being the active book and any other workbooks created by this macro being
closed. If the the file already exist, I want the macro to overwirte it
without any messages to the user.

Does anyone have any suggestion on how I can accomplished this or what I am
doing wrong.

Sub SaveTextFile()
'
' SaveTextFile Macro
'
Dim AcctYear, AcctMth
Application.ScreenUpdating = False
ActiveWorkbook.Save
Sheets("JIBUpload-OKCity").Select
Range("AcctgPeriod").Select
AcctMth = Str(Month(Range("AcctgPeriod").Value))
AcctYear = Str(Year(Range("AcctgPeriod").Value))
Sheets("JIBUpload-OKCity").Select
ActiveWorkbook.SaveAs Filename:= _
"JIBUpload" & Trim(AcctMth) & Trim(AcctYear) & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.SaveAs Filename:= _
"JIBUpload-OKCity" & Trim(AcctMth) & Trim(AcctYear) & ".txt", _
FileFormat:=xlText, CreateBackup:=False
Workbooks.Close
Workbooks("JIBUpload-OKCity.xls").Open
Application.ScreenUpdating = True
Sheets("JIBUpload-OKCity").Select
End Sub

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Saving Excel File in Current Directory NOT My Documents

To save in the current directory, include the path in the file name.
VBA Help
Filename Optional Variant. A string that indicates the name of the file
to be saved. You can include a full path; if you don't, Microsoft Excel saves
the file in the current folder.





"Fredriksson via OfficeKB.com" wrote:

I am having two issue with the code below.

The Excel wookbook that executes this code is called JIBUpload-OKCity.xls.
When code executes to the text file it changes the name of the sheet.

The results I would like is that I would like the files to be save in the
current directory not in My Documents. At the end of executing this Macro, I
would like the user to be back where they stared with JIBUpload-OKCity.xls
being the active book and any other workbooks created by this macro being
closed. If the the file already exist, I want the macro to overwirte it
without any messages to the user.

Does anyone have any suggestion on how I can accomplished this or what I am
doing wrong.

Sub SaveTextFile()
'
' SaveTextFile Macro
'
Dim AcctYear, AcctMth
Application.ScreenUpdating = False
ActiveWorkbook.Save
Sheets("JIBUpload-OKCity").Select
Range("AcctgPeriod").Select
AcctMth = Str(Month(Range("AcctgPeriod").Value))
AcctYear = Str(Year(Range("AcctgPeriod").Value))
Sheets("JIBUpload-OKCity").Select
ActiveWorkbook.SaveAs Filename:= _
"JIBUpload" & Trim(AcctMth) & Trim(AcctYear) & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.SaveAs Filename:= _
"JIBUpload-OKCity" & Trim(AcctMth) & Trim(AcctYear) & ".txt", _
FileFormat:=xlText, CreateBackup:=False
Workbooks.Close
Workbooks("JIBUpload-OKCity.xls").Open
Application.ScreenUpdating = True
Sheets("JIBUpload-OKCity").Select
End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200611/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
How do I change File Open default directory from My Documents Ben Setting up and Configuration of Excel 3 January 1st 21 12:42 PM
Excel should let me sort the file directory when saving a file Beanee70 Excel Discussion (Misc queries) 0 March 14th 06 07:03 AM
Excel should open documents in the folder of the current file boxfactory Setting up and Configuration of Excel 0 October 20th 05 03:35 PM
changing current directory to that of the current open file unnameable Excel Programming 2 May 19th 04 11:14 AM
Use Current directory to store file Paul Moles[_2_] Excel Programming 1 November 26th 03 03:04 PM


All times are GMT +1. The time now is 08:07 AM.

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"