Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Force save to CURRENT directory

Hi All...........

This code basically works, but saves to the "Excel default" directory rather
than to the directory the file came from......I want both saves to go right
back in to the same directory the file came from.......wherever that might
be. How can I force this please?

Sub NewSaveArchive()
CurrentPath = CurDir
archivepath = CurrentPath + "\" 'Default Directory
WorkBookName = ActiveWorkbook.Name
Fname = archivepath
Fname = Fname + Worksheets("INFO").Range("AH8").Value
Fname = Fname & Format(Time, "_hh_mm_ss") & Format(Date, "_Mmm_dd_yyyy")
Sheets("StaffingMatrixGF").Select
Range("a1").Select
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Fname
Fname = CurrentPath + "\" + WorkBookName
ActiveWorkbook.SaveAs Fname
Application.DisplayAlerts = True
End Sub

Vaya con Dios,
Chuck, CABGx3


  #2   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Force save to CURRENT directory

A little more info.......

If I open Excel first, and then open this file, this existing code will do
the saves to the current directory just like I want......BUT, if I open both
Excel and the file by just clicking on the filename in Windows Explorer, or a
Desktop Icon, (the preferred method), then is when Excel changes both saves
back to the default "my docments" directory specified in Tools
Options............

Any help would be appreciated......

Vaya con Dios,
Chuck, CABGx3


"CLR" wrote:

Hi All...........

This code basically works, but saves to the "Excel default" directory rather
than to the directory the file came from......I want both saves to go right
back in to the same directory the file came from.......wherever that might
be. How can I force this please?

Sub NewSaveArchive()
CurrentPath = CurDir
archivepath = CurrentPath + "\" 'Default Directory
WorkBookName = ActiveWorkbook.Name
Fname = archivepath
Fname = Fname + Worksheets("INFO").Range("AH8").Value
Fname = Fname & Format(Time, "_hh_mm_ss") & Format(Date, "_Mmm_dd_yyyy")
Sheets("StaffingMatrixGF").Select
Range("a1").Select
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Fname
Fname = CurrentPath + "\" + WorkBookName
ActiveWorkbook.SaveAs Fname
Application.DisplayAlerts = True
End Sub

Vaya con Dios,
Chuck, CABGx3


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Force save to CURRENT directory

Just use ActiveWorkbook.Path to get the save location. Something
like:
CurrentPath = ActiveWorkbook.Path
Fname = CurrentPath & "\" & Worksheets("INFO").Range("AH8").Value
ActiveWorkbook.SaveAs Fname

CLR wrote:
Hi All...........

This code basically works, but saves to the "Excel default" directory rather
than to the directory the file came from......I want both saves to go right
back in to the same directory the file came from.......wherever that might
be. How can I force this please?

Sub NewSaveArchive()
CurrentPath = CurDir
archivepath = CurrentPath + "\" 'Default Directory
WorkBookName = ActiveWorkbook.Name
Fname = archivepath
Fname = Fname + Worksheets("INFO").Range("AH8").Value
Fname = Fname & Format(Time, "_hh_mm_ss") & Format(Date, "_Mmm_dd_yyyy")
Sheets("StaffingMatrixGF").Select
Range("a1").Select
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Fname
Fname = CurrentPath + "\" + WorkBookName
ActiveWorkbook.SaveAs Fname
Application.DisplayAlerts = True
End Sub

Vaya con Dios,
Chuck, CABGx3


  #4   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Force save to CURRENT directory

Fine.....FINE........SUPERFINE!!!
Thank you very much kind Sir.

Vaya con Dios,
Chuck, CABGx3



"JW" wrote:

Just use ActiveWorkbook.Path to get the save location. Something
like:
CurrentPath = ActiveWorkbook.Path
Fname = CurrentPath & "\" & Worksheets("INFO").Range("AH8").Value
ActiveWorkbook.SaveAs Fname

CLR wrote:
Hi All...........

This code basically works, but saves to the "Excel default" directory rather
than to the directory the file came from......I want both saves to go right
back in to the same directory the file came from.......wherever that might
be. How can I force this please?

Sub NewSaveArchive()
CurrentPath = CurDir
archivepath = CurrentPath + "\" 'Default Directory
WorkBookName = ActiveWorkbook.Name
Fname = archivepath
Fname = Fname + Worksheets("INFO").Range("AH8").Value
Fname = Fname & Format(Time, "_hh_mm_ss") & Format(Date, "_Mmm_dd_yyyy")
Sheets("StaffingMatrixGF").Select
Range("a1").Select
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Fname
Fname = CurrentPath + "\" + WorkBookName
ActiveWorkbook.SaveAs Fname
Application.DisplayAlerts = True
End Sub

Vaya con Dios,
Chuck, CABGx3



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Force save to CURRENT directory

On Oct 26, 2:54 am, CLR wrote:
Fine.....FINE........SUPERFINE!!!
Thank you very much kind Sir.

Vaya con Dios,
Chuck, CABGx3



"JW" wrote:
Just use ActiveWorkbook.Path to get the save location. Something
like:
CurrentPath = ActiveWorkbook.Path
Fname = CurrentPath & "\" & Worksheets("INFO").Range("AH8").Value
ActiveWorkbook.SaveAs Fname


CLR wrote:
Hi All...........


This code basically works, but saves to the "Excel default" directory rather
than to the directory the file came from......I want both saves to go right
back in to the same directory the file came from.......wherever that might
be. How can I force this please?


Sub NewSaveArchive()
CurrentPath = CurDir
archivepath = CurrentPath + "\" 'Default Directory
WorkBookName = ActiveWorkbook.Name
Fname = archivepath
Fname = Fname + Worksheets("INFO").Range("AH8").Value
Fname = Fname & Format(Time, "_hh_mm_ss") & Format(Date, "_Mmm_dd_yyyy")
Sheets("StaffingMatrixGF").Select
Range("a1").Select
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Fname
Fname = CurrentPath + "\" + WorkBookName
ActiveWorkbook.SaveAs Fname
Application.DisplayAlerts = True
End Sub


Vaya con Dios,
Chuck, CABGx3- Hide quoted text -


- Show quoted text -


try this;
ThisWorkbook.Activate
FilePath = Left(thisworkbook.FullName,Len(thisworkbook.FullNa me)-
Len(thisworkbook.Name))

This should save the active workbook file directory to FilePath. Just
add the file name.

Regards
trevosef



  #6   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Force save to CURRENT directory

Thanks for the response trevosef, but I have already used JW's suggestion,
which worked ok for me in this application.

Vaya con Dios,
Chuck, CABGx3


" wrote:

On Oct 26, 2:54 am, CLR wrote:
Fine.....FINE........SUPERFINE!!!
Thank you very much kind Sir.

Vaya con Dios,
Chuck, CABGx3



"JW" wrote:
Just use ActiveWorkbook.Path to get the save location. Something
like:
CurrentPath = ActiveWorkbook.Path
Fname = CurrentPath & "\" & Worksheets("INFO").Range("AH8").Value
ActiveWorkbook.SaveAs Fname


CLR wrote:
Hi All...........


This code basically works, but saves to the "Excel default" directory rather
than to the directory the file came from......I want both saves to go right
back in to the same directory the file came from.......wherever that might
be. How can I force this please?


Sub NewSaveArchive()
CurrentPath = CurDir
archivepath = CurrentPath + "\" 'Default Directory
WorkBookName = ActiveWorkbook.Name
Fname = archivepath
Fname = Fname + Worksheets("INFO").Range("AH8").Value
Fname = Fname & Format(Time, "_hh_mm_ss") & Format(Date, "_Mmm_dd_yyyy")
Sheets("StaffingMatrixGF").Select
Range("a1").Select
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Fname
Fname = CurrentPath + "\" + WorkBookName
ActiveWorkbook.SaveAs Fname
Application.DisplayAlerts = True
End Sub


Vaya con Dios,
Chuck, CABGx3- Hide quoted text -


- Show quoted text -


try this;
ThisWorkbook.Activate
FilePath = Left(thisworkbook.FullName,Len(thisworkbook.FullNa me)-
Len(thisworkbook.Name))

This should save the active workbook file directory to FilePath. Just
add the file name.

Regards
trevosef


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
Change current directory to the directory that the workbook loads from! alondon Excel Programming 5 April 17th 07 06:05 AM
Force use of the Default Directory CLR Excel Programming 3 February 6th 07 09:20 PM
How do I force an Excel macro to ask me which file and directory? Ramius Excel Discussion (Misc queries) 4 January 14th 05 03:26 PM
How to force current directory CLR Excel Programming 8 November 30th 04 01:11 AM
changing current directory to that of the current open file unnameable Excel Programming 2 May 19th 04 11:14 AM


All times are GMT +1. The time now is 04:34 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"