LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Saving to same directory

Hi All,

Sorry if this is a little long winded.

I project that requies a suite of 3 workbooks to all be located in the same
directory. The user is asked to make choices in the 1st workbook which will
determine the format / layout in the 2nd & 3rd workbooks. The 2nd and 3rd
workbooks are in the form of a template (but not actually an Excel template)
and are amended to reflect the formatiing in the 1st workbook. Using VBA
code they are then saved using a different name so that the templates are
preserved.

The problem l am having is that l cannot get the VBA code to save the
re-named workbooks in the same directory that the original suite of 3
workbooks reside.

The project is to be used by many people across a network so the directory
path / folder names etc cannot be hard coded.

If l assign the current directory of the 1st workbook to a variable (using
"CurDir"), and then use the "ChDir" function before saving the workbook l it
is not always saved to the correct directory.

I believe that the file is always being saved to the same directory as the
user last used when using the built in Excel SaveAs command.

Any help gratefully received.

The VBA code used to save the workbook is below :

Sub Export_Data()

Dim wsName
Dim thisBLB

wsName = ThisWorkbook.Name

Application.EnableEvents = False
Application.ScreenUpdating = False

Workbooks.Open ThisWorkbook.Path & "\BLBxxxxCAFT"
Sheets("Import").Activate
Range("A1:E1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Windows(wsName).Activate
Sheets("Vision Extract").Activate
Range("AC3").Activate
thisBLB = ActiveCell.Value
Range("Y2:AC2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("BLBxxxxCAFT.xls").Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlValues
Selection.Columns.AutoFit
Range("A1").Select
Workbooks("BLBxxxxCAFT.xls").Close SaveChanges:=True,
Filename:=(ThisWorkbook.Path & "\BLB" & thisBLB & "CAFT")

Regards

Michael Beckinsale


 
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
set default directory for saving files Vibeke Excel Discussion (Misc queries) 5 August 23rd 07 12:52 PM
How to change options for saving when old directory(network) gone Mel Ackerman Setting up and Configuration of Excel 3 August 10th 06 10:10 PM
Saving to root directory ChrisP Excel Discussion (Misc queries) 2 July 31st 06 02:10 AM
Why is Word, Excel saving a backup copy in my temp directory? daddyribs Excel Discussion (Misc queries) 1 April 19th 06 04:24 PM
Saving into new directory Greg B Excel Discussion (Misc queries) 2 March 2nd 05 03:58 PM


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