Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Saving templete / workbook to a specific drive / file

I have a workbook template which when team members use it and the
they go to save it defaults to “my documents” and I would like to set
up a macro to save it to a particular drive / file location.

Below is one that works for a word template that I use, but I don’t
think it will work with an Excel file.

Excel 2003

Any Ideas ?

John


Credit to Graham Mayor

For these macros.

Sub FileSaveAs()
Dim sPath As String
sPath = "S:\Duty & Assessment\DAT ONLY" 'set the default save as path
for the document
On Error Resume Next
ChDir sPath 'Change to the directory you wish to save in
If Err.Number = 76 Then 'that folder doesn't exist

MsgBox sPath & " is not available on this PC?" & vbCr & "Select
the correct folder to save the document"
End If
With Dialogs(wdDialogFileSaveAs)

.Name = sPath & "\"
.Show 'show the save dialog
End With
End Sub


Sub FileSave()
Dim sPath As String
sPath = "S:\Duty & Assessment\DAT ONLY" 'set the default save as path
for the document
On Error Resume Next
If Len(ActiveDocument.Path) 0 Then 'the document has been previously
saved
ActiveDocument.Save 'so save the changes
Else 'The document has not been saved
ChDir sPath 'Change to the directory you wish to save in
If Err.Number = 76 Then 'that folder doesn't exist

MsgBox sPath & " is not available on this PC?" & vbCr & "Select
the correct folder to save the document"
End If
With Dialogs(wdDialogFileSaveAs)

.Name = sPath & "\"
.Show 'show the save dialog
End With
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Saving templete / workbook to a specific drive / file

This could be a quick & dirty (and very clumsy) solution but have you
looked at something like this:

'Should go into ThisWorkbook object coed
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Me.SaveAs "the full name goes here" '<-- amend as necessary
Cancel = True
End Sub

As i said - it's an ugly one (+ its recoursive) but it should get you
started.
Getting the destination name file name would be no different from what
you do in Word.


On Sep 29, 7:26*pm, Johnnyboy5 wrote:
I have a workbook template which when team members *use it *and the
they go to save it defaults to “my documents” and I would like to set
up a macro to save it to a particular drive / file location.

Below is one that works for a word template that I use, *but I don’t
think it will work with an Excel file.

Excel *2003

Any Ideas ?

John

Credit to Graham Mayor *


For these macros.

Sub FileSaveAs()
Dim sPath As String
sPath = "S:\Duty & Assessment\DAT ONLY" 'set the default save as path
for the document
On Error Resume Next
ChDir sPath 'Change to the directory you wish to save in
If Err.Number = 76 Then 'that folder doesn't exist

* * MsgBox sPath & " is not available on this PC?" & vbCr & "Select
the correct folder to save the document"
End If
With Dialogs(wdDialogFileSaveAs)

* * .Name = sPath & "\"
* * .Show 'show the save dialog
End With
End Sub

Sub FileSave()
Dim sPath As String
sPath = "S:\Duty & Assessment\DAT ONLY" 'set the default save as path
for the document
On Error Resume Next
If Len(ActiveDocument.Path) 0 Then 'the document has been previously
saved
* *ActiveDocument.Save 'so save the changes
Else 'The document has not been saved
* *ChDir sPath 'Change to the directory you wish to save in
* *If Err.Number = 76 Then 'that folder doesn't exist

* * * *MsgBox sPath & " is not available on this PC?" & vbCr & "Select
the correct folder to save the document"
* *End If
* *With Dialogs(wdDialogFileSaveAs)

* * * *.Name = sPath & "\"
* * * *.Show 'show the save dialog
* *End With
End If
End Sub


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
Saving Excel File to a Network Drive Jason Excel Discussion (Misc queries) 2 March 2nd 10 05:16 PM
saving office 2003 file to share drive Lisa Excel Discussion (Misc queries) 1 December 4th 08 08:49 PM
Saving Workbook in a shared drive al_ba Excel Programming 8 October 4th 08 01:18 PM
Error Trapping saving file to network drive Gazza Excel Programming 2 September 25th 06 06:49 PM
save workbook created from templete to a specific folder imh Excel Discussion (Misc queries) 1 June 2nd 06 11:29 PM


All times are GMT +1. The time now is 05:46 AM.

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"