Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Stopping a macro to edit the template then re-saving the macro for use

Hi

I am nearly there - for what I need anyway.

The macro below doesn't allow me to edit the sheet (template sheet)
and re-save it as a "template" it will only save as a file.

How to I stop the macro from running the save function in order that I
can save it as a template - but at the same time know that when the
template is used it will run the macro.

Johnnny






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







' Place the current files path and filename in the titlebar:
Windows(1).Caption = ActiveWorkbook.FullName



' Place your own application name in the titlebar:
Application.Caption = "SPICE SHEET FOLDER"





Cancel = True
ActiveWorkbook.Saved = True
msg = MsgBox("The workbook has been saved as " & ms, vbInformation +
vbOKOnly, "Save As")
Application.DisplayFullScreen = False
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Stopping a macro to edit the template then re-saving the macrofor use

On Oct 3, 8:06*am, Johnnyboy5 wrote:
Hi

I am nearly there - for what I need anyway.

The macro below doesn't allow me to edit the sheet (template sheet)
and re-save it as a *"template" it will only save as a file.

How to I stop the macro from running the save function in order that I
can save it as a template - but at the same time know that when the
template is used it will run the macro.

Johnnny

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

' Place the current files path and filename in the titlebar:
* * * Windows(1).Caption = ActiveWorkbook.FullName

* * * ' Place your own application name in the titlebar:
* * * Application.Caption = "SPICE SHEET FOLDER"

Cancel = True
ActiveWorkbook.Saved = True
msg = MsgBox("The workbook has been saved as " & ms, vbInformation +
vbOKOnly, "Save As")
Application.DisplayFullScreen = False
End Sub


You could have had your saveAS assigned to a button/shape. The way you
have it, just comment out (put an apostophe) in front of the macro to
NOT fire it. Save and then UN comment to go back to where you are now.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Stopping a macro to edit the template then re-saving the macrofor use

On 3 Oct, 14:17, Don Guillett Excel MVP
wrote:
On Oct 3, 8:06*am, Johnnyboy5 wrote:





Hi


I am nearly there - for what I need anyway.


The macro below doesn't allow me to edit the sheet (template sheet)
and re-save it as a *"template" it will only save as a file.


How to I stop the macro from running the save function in order that I
can save it as a template - but at the same time know that when the
template is used it will run the macro.


Johnnny


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


' Place the current files path and filename in the titlebar:
* * * Windows(1).Caption = ActiveWorkbook.FullName


* * * ' Place your own application name in the titlebar:
* * * Application.Caption = "SPICE SHEET FOLDER"


Cancel = True
ActiveWorkbook.Saved = True
msg = MsgBox("The workbook has been saved as " & ms, vbInformation +
vbOKOnly, "Save As")
Application.DisplayFullScreen = False
End Sub


You could have had your saveAS assigned to a button/shape. The way you
have it, just comment out (put an apostophe) in front of the macro to
NOT fire it. Save and then UN comment to go back to where you are now.


Thanks - tried that but when I save the template it saves the macro
with the apostophe it doesnt run the macro again when I want to use
the template to create a new record. When I then remove the apostophe
again the macro wont let me save it as a template.

I dont really want the end user to use any buttons etc, I would like
it all just to happen in the back ground.

regards

John
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Stopping a macro to edit the template then re-saving the macrofor use

On Oct 3, 9:06*am, Johnnyboy5 wrote:
On 3 Oct, 14:17, Don Guillett Excel MVP
wrote:





On Oct 3, 8:06*am, Johnnyboy5 wrote:


Hi


I am nearly there - for what I need anyway.


The macro below doesn't allow me to edit the sheet (template sheet)
and re-save it as a *"template" it will only save as a file.


How to I stop the macro from running the save function in order that I
can save it as a template - but at the same time know that when the
template is used it will run the macro.


Johnnny


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


' Place the current files path and filename in the titlebar:
* * * Windows(1).Caption = ActiveWorkbook.FullName


* * * ' Place your own application name in the titlebar:
* * * Application.Caption = "SPICE SHEET FOLDER"


Cancel = True
ActiveWorkbook.Saved = True
msg = MsgBox("The workbook has been saved as " & ms, vbInformation +
vbOKOnly, "Save As")
Application.DisplayFullScreen = False
End Sub


You could have had your saveAS assigned to a button/shape. The way you
have it, just comment out (put an apostophe) in front of the macro to
NOT fire it. Save and then UN comment to go back to where you are now.


Thanks *- tried that but when I save the template it saves the macro
with the apostophe it doesnt run the macro again when I want to use
the template to create a new record. *When I then remove the apostophe
again the macro wont let me save it as a template.

I dont really want the end user to use any buttons etc, *I would like
it all just to happen in the back ground.

regards

John- Hide quoted text -

- Show quoted text -


"People in hell want ice water"
You could have an inputbox message asking what you want to do but,
again, this requires effort on your part
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Stopping a macro to edit the template then re-saving the macrofor use

On 3 Oct, 15:31, Don Guillett Excel MVP
wrote:
On Oct 3, 9:06*am, Johnnyboy5 wrote:





On 3 Oct, 14:17, Don Guillett Excel MVP
wrote:


On Oct 3, 8:06*am, Johnnyboy5 wrote:


Hi


I am nearly there - for what I need anyway.


The macro below doesn't allow me to edit the sheet (template sheet)
and re-save it as a *"template" it will only save as a file.


How to I stop the macro from running the save function in order that I
can save it as a template - but at the same time know that when the
template is used it will run the macro.


Johnnny


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


' Place the current files path and filename in the titlebar:
* * * Windows(1).Caption = ActiveWorkbook.FullName


* * * ' Place your own application name in the titlebar:
* * * Application.Caption = "SPICE SHEET FOLDER"


Cancel = True
ActiveWorkbook.Saved = True
msg = MsgBox("The workbook has been saved as " & ms, vbInformation +
vbOKOnly, "Save As")
Application.DisplayFullScreen = False
End Sub


You could have had your saveAS assigned to a button/shape. The way you
have it, just comment out (put an apostophe) in front of the macro to
NOT fire it. Save and then UN comment to go back to where you are now..


Thanks *- tried that but when I save the template it saves the macro
with the apostophe it doesnt run the macro again when I want to use
the template to create a new record. *When I then remove the apostophe
again the macro wont let me save it as a template.


I dont really want the end user to use any buttons etc, *I would like
it all just to happen in the back ground.


regards


John- Hide quoted text -


- Show quoted text -


"People in hell want ice water"
You could have an inputbox message asking what you want to do but,
again, this requires effort on your part


Mmm fair comment...


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
Stopping A Macro Mike Lewis Excel Programming 4 July 11th 08 01:29 PM
Stopping a macro DJ Excel Programming 13 October 22nd 07 06:40 PM
Stopping a Macro Felix Excel Programming 10 August 14th 07 12:20 PM
Problem with saving Excel Template opened in macro KelliInCali Excel Programming 2 September 5th 06 08:00 PM
Stopping a Macro Paul Excel Programming 2 December 7th 05 02:11 PM


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