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

I am using the following code in the "before save" declaration in the
workbook code. It works great except for one problem. It doesn't save the
workbook in the directory I want it to. How do I get it to save in a certain
directory/folder?

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.EnableEvents = False
Cancel = True
ThisWorkbook.SaveAs Worksheets("DEVIATION REPORT").Range("AM49").Value
Application.EnableEvents = True

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default save in directory

Specify the fully qualified path name:

e.g to save Worksheets("DEVIATION REPORT").Range("AM49").Value

to the default path

application.defaultfilepath & "\" & Worksheets("DEVIATION
REPORT").Range("AM49").Value

to save to "c:\xx"

"c:\xx" & "\" & Worksheets("DEVIATION REPORT").Range("AM49").Value

The path must exists or it will fail.

"rlm" wrote:

I am using the following code in the "before save" declaration in the
workbook code. It works great except for one problem. It doesn't save the
workbook in the directory I want it to. How do I get it to save in a certain
directory/folder?

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.EnableEvents = False
Cancel = True
ThisWorkbook.SaveAs Worksheets("DEVIATION REPORT").Range("AM49").Value
Application.EnableEvents = True

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default save in directory


Include the path


ThisWorkbook.SaveAs "c:\test " & Worksheets("DEVIATION
REPORT").Range("AM49").Value


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=536682

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
Save file to same directory folder RobN[_2_] Excel Discussion (Misc queries) 2 April 4th 10 08:06 AM
Automatically save a file in another directory MarkT Excel Discussion (Misc queries) 4 September 18th 06 02:53 PM
open in old directory save in new directory tim64[_2_] Excel Programming 0 June 15th 05 07:48 PM
Save to directory and create if not exist Rob Excel Programming 8 January 29th 05 05:39 PM
Save File to Another Directory, but not change Users File Save location Mike Knight Excel Programming 1 May 28th 04 09:06 PM


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