Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default save as cell A1 to to a specific drive

Hi

When I use the macro below it does save the file as per cell A1 and
it does save it to the chosen drive. But it then closes Excel.

On checking the file location it is saved there.

Any ideas what’s wrong.

Thanks

John


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim FileSaveName


ChDrive "H"
ChDir "H:\Temp"


ThisFile = Range("A1").Value
ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default save as cell A1 to to a specific drive

On Oct 2, 6:29*am, Johnnyboy5 wrote:
Hi

When I use the macro below *it does save the file as per cell A1 and
it does save it to the chosen drive. * But it then closes Excel.

On checking the file location it is saved there.

Any ideas what’s wrong.

Thanks

John

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
* * Dim FileSaveName

* * ChDrive "H"
* * ChDir "H:\Temp"

* * ThisFile = Range("A1").Value
* * ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub


Try it this way (saveCOPYas) to also avoid changing the default dir
\folder. Also, includes the sheet & .xls

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
mydrive = "H:"
mydir = "Temp"
myname = Sheets("sheet1").Range("a1")
ms = mydrive & "\" & mydir & "\" & myname & ".xls"
ActiveWorkbook.SaveCopyAs Filename:=ms
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default save as cell A1 to to a specific drive

On 2 Oct, 13:48, Don Guillett Excel MVP
wrote:
On Oct 2, 6:29*am, Johnnyboy5 wrote:





Hi


When I use the macro below *it does save the file as per cell A1 and
it does save it to the chosen drive. * But it then closes Excel.


On checking the file location it is saved there.


Any ideas what’s wrong.


Thanks


John


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
* * Dim FileSaveName


* * ChDrive "H"
* * ChDir "H:\Temp"


* * ThisFile = Range("A1").Value
* * ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub


Try it this way (saveCOPYas) to also avoid changing the default dir
\folder. Also, includes the sheet & .xls

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
mydrive = "H:"
mydir = "Temp"
myname = Sheets("sheet1").Range("a1")
ms = mydrive & "\" & mydir & "\" & myname & ".xls"
ActiveWorkbook.SaveCopyAs Filename:=ms
End Sub


Hi

thanks - however doesnt appear to work.

John
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default save as cell A1 to to a specific drive

On 2 Oct, 14:12, Johnnyboy5 wrote:
On 2 Oct, 13:48, Don Guillett Excel MVP
wrote:





On Oct 2, 6:29*am, Johnnyboy5 wrote:


Hi


When I use the macro below *it does save the file as per cell A1 and
it does save it to the chosen drive. * But it then closes Excel.


On checking the file location it is saved there.


Any ideas what’s wrong.


Thanks


John


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
* * Dim FileSaveName


* * ChDrive "H"
* * ChDir "H:\Temp"


* * ThisFile = Range("A1").Value
* * ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub


Try it this way (saveCOPYas) to also avoid changing the default dir
\folder. Also, includes the sheet & .xls


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
mydrive = "H:"
mydir = "Temp"
myname = Sheets("sheet1").Range("a1")
ms = mydrive & "\" & mydir & "\" & myname & ".xls"
ActiveWorkbook.SaveCopyAs Filename:=ms
End Sub


Hi

thanks - however doesnt appear to work.

John


Sorry it does work - what is confusing is that when you go to file
save as - it show "documents" even thought the file does save to "my
dir" etc.

The issue is the other people who will be using this sheet wont
understand where its been save to - is there a way to change that
dialog box so it shows its saved to "mydir" etc

John
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 workbook To any USB Drive no matter what drive letter pano[_3_] Excel Programming 9 July 15th 08 09:41 AM
Can I save to hard drive AND my flash drive at the same time? Gizelle Excel Discussion (Misc queries) 3 July 24th 06 08:27 PM
Save to hard drive and backup to thumb drive. sungen99[_34_] Excel Programming 22 January 27th 06 01:17 PM
How do I use a macro to save to a specific drive in Excel? Meredith Excel Programming 2 August 23rd 05 02:29 PM
Prgrammatically save a file to a specific folder on a network drive Ajit[_3_] Excel Programming 1 April 2nd 04 04:55 AM


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

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

About Us

"It's about Microsoft Excel"