Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default close file disable toolbar

Is there a way to force user to close file with a buttom macro and disable
the regualr closing opcions like close, exit and X at top right corner?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default close file disable toolbar

From workbook press Alt+F11 to launch VBE (Visual Basic Editor). From the
left treeview search for the workbook name and click on + to expand it.
Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub


Insert a module and copy the below macro..which is to be assigned to a button

Sub CloseBook()
ThisWorkbook.Close True
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

Is there a way to force user to close file with a buttom macro and disable
the regualr closing opcions like close, exit and X at top right corner?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default close file disable toolbar

This is great... I thought it was not going to be posible... but still I
asked and I glad....

First part worked great... but could not get the file to close with the macro.

Do I need a special module or can be in one of the currently used modules...?
Any other idea why the close book is not working?

"Jacob Skaria" wrote:

From workbook press Alt+F11 to launch VBE (Visual Basic Editor). From the
left treeview search for the workbook name and click on + to expand it.
Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub


Insert a module and copy the below macro..which is to be assigned to a button

Sub CloseBook()
ThisWorkbook.Close True
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

Is there a way to force user to close file with a buttom macro and disable
the regualr closing opcions like close, exit and X at top right corner?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default close file disable toolbar

I am sure there is something wrong in the way you are trying.

--From a saved workbook launch VBE using short-key Alt+F11.
--From menu 'Insert' a module and paste the below code.
--Get back to Workbook. Save workbook
--Run macro from Tools|Macro|Run <selected macro()

Sub Macrotest()
ThisWorkbook.Close True
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

This is great... I thought it was not going to be posible... but still I
asked and I glad....

First part worked great... but could not get the file to close with the macro.

Do I need a special module or can be in one of the currently used modules...?
Any other idea why the close book is not working?

"Jacob Skaria" wrote:

From workbook press Alt+F11 to launch VBE (Visual Basic Editor). From the
left treeview search for the workbook name and click on + to expand it.
Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub


Insert a module and copy the below macro..which is to be assigned to a button

Sub CloseBook()
ThisWorkbook.Close True
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

Is there a way to force user to close file with a buttom macro and disable
the regualr closing opcions like close, exit and X at top right corner?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default close file disable toolbar

I have made a lot of macros... I know what you mean to insert codes on This
Workbook and inserting a module and pasting the macro commands and assigning
it to a buttom... but it does not close... would you review the commands
inserted on "This Workbook".

Thanks.

"Jacob Skaria" wrote:

I am sure there is something wrong in the way you are trying.

--From a saved workbook launch VBE using short-key Alt+F11.
--From menu 'Insert' a module and paste the below code.
--Get back to Workbook. Save workbook
--Run macro from Tools|Macro|Run <selected macro()

Sub Macrotest()
ThisWorkbook.Close True
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

This is great... I thought it was not going to be posible... but still I
asked and I glad....

First part worked great... but could not get the file to close with the macro.

Do I need a special module or can be in one of the currently used modules...?
Any other idea why the close book is not working?

"Jacob Skaria" wrote:

From workbook press Alt+F11 to launch VBE (Visual Basic Editor). From the
left treeview search for the workbook name and click on + to expand it.
Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub


Insert a module and copy the below macro..which is to be assigned to a button

Sub CloseBook()
ThisWorkbook.Close True
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

Is there a way to force user to close file with a buttom macro and disable
the regualr closing opcions like close, exit and X at top right corner?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default close file disable toolbar

OK..I have tried with 2003 and 2007 versions..Since the button is on the
active workbook you cab try the below

Sub Macrotest()
Activeworkbook.Close True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

I have made a lot of macros... I know what you mean to insert codes on This
Workbook and inserting a module and pasting the macro commands and assigning
it to a buttom... but it does not close... would you review the commands
inserted on "This Workbook".

Thanks.

"Jacob Skaria" wrote:

I am sure there is something wrong in the way you are trying.

--From a saved workbook launch VBE using short-key Alt+F11.
--From menu 'Insert' a module and paste the below code.
--Get back to Workbook. Save workbook
--Run macro from Tools|Macro|Run <selected macro()

Sub Macrotest()
ThisWorkbook.Close True
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

This is great... I thought it was not going to be posible... but still I
asked and I glad....

First part worked great... but could not get the file to close with the macro.

Do I need a special module or can be in one of the currently used modules...?
Any other idea why the close book is not working?

"Jacob Skaria" wrote:

From workbook press Alt+F11 to launch VBE (Visual Basic Editor). From the
left treeview search for the workbook name and click on + to expand it.
Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub


Insert a module and copy the below macro..which is to be assigned to a button

Sub CloseBook()
ThisWorkbook.Close True
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

Is there a way to force user to close file with a buttom macro and disable
the regualr closing opcions like close, exit and X at top right corner?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default close file disable toolbar

If you dont want to save changes you can try

Activeworkbook.Close False

If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

I have made a lot of macros... I know what you mean to insert codes on This
Workbook and inserting a module and pasting the macro commands and assigning
it to a buttom... but it does not close... would you review the commands
inserted on "This Workbook".

Thanks.

"Jacob Skaria" wrote:

I am sure there is something wrong in the way you are trying.

--From a saved workbook launch VBE using short-key Alt+F11.
--From menu 'Insert' a module and paste the below code.
--Get back to Workbook. Save workbook
--Run macro from Tools|Macro|Run <selected macro()

Sub Macrotest()
ThisWorkbook.Close True
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

This is great... I thought it was not going to be posible... but still I
asked and I glad....

First part worked great... but could not get the file to close with the macro.

Do I need a special module or can be in one of the currently used modules...?
Any other idea why the close book is not working?

"Jacob Skaria" wrote:

From workbook press Alt+F11 to launch VBE (Visual Basic Editor). From the
left treeview search for the workbook name and click on + to expand it.
Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub


Insert a module and copy the below macro..which is to be assigned to a button

Sub CloseBook()
ThisWorkbook.Close True
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

Is there a way to force user to close file with a buttom macro and disable
the regualr closing opcions like close, exit and X at top right corner?

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
Excel 2007: How do I disable the 'Do you wish to save changes to...' when I close an un changed file? anctech Excel Discussion (Misc queries) 4 June 15th 07 10:42 AM
Disable Close All LoDawg Excel Programming 1 November 7th 06 12:32 AM
Disable Close Button dan Excel Discussion (Misc queries) 5 September 22nd 06 07:39 PM
How to disable save message when I click the cross to close the file hon123456 Excel Programming 2 June 21st 06 07:17 AM
Disable Macros --> Close File [email protected] Setting up and Configuration of Excel 3 August 24th 05 10:22 PM


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