Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Autorun macros on opening

HI guys,

I am trying to setup a autorun macro on a workbook I have. I am trying
to stop the rest of the office changing the name of this file, as it
wil l have a knock on effect to other report!


How do I set this up, I have tried numerous examples on this site, but
just can't get them working... I was looking also for the code that
will stop users using the SaveAs function on the master template I am
creating..


Your help is greatly appreciated.


Craigy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Autorun macros on opening


Hi, paste this in to the "This Workbook" module

Private Sub Workbook_BeforeSave _
(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI = True Then Cancel = True
End Sub

paste this in to an ordinary module:

Sub Auto_open()
On Error Resume Next
If ThisWorkbook.Name < "Test" Then
Application.Quit
End If
End Sub

If the workbook name is not EXACTLY like the wording "Test" then you
will not be able to open the workbook again, if you had the workbook
named "test" you still would not be able to open it, it MUST be exact!

Regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=569278

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Autorun macros on opening

Hi Simon,

Thanks for this.

I don't quite understand the workings behind these, I am sorry, I am
only very new to this. Once I have a grasp of how these work, I can
getting them into my template.

What is "This Workbook" and "Ordinary Module"??

Thanks in advance

Thanks

C


Simon Lloyd wrote:
Hi, paste this in to the "This Workbook" module

Private Sub Workbook_BeforeSave _
(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI = True Then Cancel = True
End Sub

paste this in to an ordinary module:

Sub Auto_open()
On Error Resume Next
If ThisWorkbook.Name < "Test" Then
Application.Quit
End If
End Sub

If the workbook name is not EXACTLY like the wording "Test" then you
will not be able to open the workbook again, if you had the workbook
named "test" you still would not be able to open it, it MUST be exact!

Regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=569278


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Autorun macros on opening


In Excel click on tools, macros, Visual Basic Editor, when it opens yo
will see the worksheet modules and the This Workbook module doulbl
click it to open it!, for an ordinary module right click on Thi
Workbook module choose Insert then choose Module.

Regards,
Simo

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=56927

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
How do I prevent AutoRun Macros when Programmatically Opening Workbook? Joseph Geretz Excel Programming 27 March 26th 06 11:26 PM
AutoRun Excel Macros JD Excel Programming 5 May 26th 05 08:51 PM
Autorun Macro on file opening Sha-auto[_2_] Excel Programming 1 October 27th 04 04:31 PM
Autorun Macro on file opening Sha-auto Excel Programming 3 October 26th 04 03:53 AM
Autorun macro on opening spreadsheet simonjackson79 Excel Programming 3 November 5th 03 02:22 PM


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