470,612 Members | 2,524 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,612 developers. It's quick & easy.

How to hide excel close button programatically

Hello all,
I have to open a readonly Excel sheet from clicking on a button on an access
form. So far no problem:
Dim ObjXL As Excel.Application
Dim ObjXLBook As Excel.Workbook
Dim ObjXLSheet As Excel.Worksheet
Set ObjXL = CreateObject("Excel.Application")
Set ObjXLBook = ObjXL.Workbooks.Open("Mypath\Myfile.xls", , True)
Set ObjXLSheet = ObjXLBook.Worksheets("Main")
ObjXL.Visible = True

Then the user puts in the data. However, I want to prevent him from giving
it the wrong name and save it in the wrong place.
So I want to hide the close button on the sheet and insert a custom button
which gives the file the right name and saves it at the right place (path).
So my questions are ... How do I hide the close button when opening the file
(if at all possible) and what is the correct code to put on the onclick
event of the custom button to give it the right name and right place ?
Any help very much appreciated.
Ronny
Nov 12 '05 #1
2 4519
You can't hide the close button. If you have control over the origination of
MyFile.xls, then you could add code to it that would prevent anyone from
closing the workbook unless they used your special button.

If you DON'T have control over the origination of MyFile, then I have two
options for you, since you seem to KNOW what to name the file and where to put
it BEFORE they even open the file:

1) Before opening it, copy it to the new name/location, and make it editable

2) After the user gets back to Access, test for the name/path (using DIR
function), and pop up an appropriate guilt message as needed.
Nov 12 '05 #2
Thank you, this sure helps
Ronny
"DCM Fan" <dc****@aol.comSPNOAM> schreef in bericht
news:20***************************@mb-m01.aol.com...
You can't hide the close button. If you have control over the origination of MyFile.xls, then you could add code to it that would prevent anyone from
closing the workbook unless they used your special button.

If you DON'T have control over the origination of MyFile, then I have two
options for you, since you seem to KNOW what to name the file and where to put it BEFORE they even open the file:

1) Before opening it, copy it to the new name/location, and make it editable
2) After the user gets back to Access, test for the name/path (using DIR
function), and pop up an appropriate guilt message as needed.

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Vikram | last post: by
6 posts views Thread by Matthew Wieder | last post: by
1 post views Thread by Andre Ranieri | last post: by
5 posts views Thread by dje | last post: by
1 post views Thread by sorcerdon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.