View Full Version : Solved: is it possible to disable xl2003 file open in xl2007+
mancubus
01-19-2011, 08:56 AM
hi board.
workbook_open procedure disables (and beforeclose reenables) Insert, Format, Tools, Data and File (only save as, save as web page, save workspace, print) controls and ctrl+p (print) and F12 (save as) keys. (i wish i could also disable additional controls such as ctrl+c, ctrl+v, etc. in this file. must be enabled.)
but if the file is opened in 2007+, all features disabled become enabled.
the file has to be in 2003 format. so i seek a solution to force the user open the file in xl2003.
p45cal
01-19-2011, 09:28 AM
workbook_open procedure disables What's the code look like?
the file has to be in 2003 format. Why? (Just so the disabling takes place?)
so i seek a solution to force the user open the file in xl2003This is going to limit the viability of the file though, isn't it? Fewer and fewer people will have access to Excel 2003.
Perhaps you could go down the route of the procedure identifying which version of Excel is being used to open the file and using different code to disable that which needs to be disabled. (I've never done disabling, which is why I want to see your code)
mancubus
01-19-2011, 09:39 AM
thx for replying.
for the purpose of this project, 2003 is OK. all possible users have access to xl2003.
this helped for disabling keys:
http://www.rondebruin.nl/key.htm
and this for controls:
http://www.rondebruin.nl/menuid.htm
ex:
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=4, Recursive:=True).Enabled = False 'disables Print
Application.CommandBars("Worksheet Menu Bar").Controls("Insert").Enabled = False 'disables Insert
Application.OnKey "^p", "" 'disables ctrl+p
Application.OnKey "{F12}", ""
Application.OnKey "^p" 'enables ctrl+p
p45cal
01-19-2011, 09:57 AM
Perhaps:Private Sub Workbook_Open()
If Not Application.Version = "11.0" Then
MsgBox "Please only open this file in Excel 2003"
ThisWorkbook.Close
End If
End Sub
but of course, this won't stop people disabling macros.
mancubus
01-19-2011, 10:04 AM
this did the trick. thanks pascal
Perhaps you could go down the route of the procedure identifying which version of Excel is being used to open the file and using different code to disable that which needs to be disabled. (I've never done disabling, which is why I want to see your code)
i added the following lines in workbook_open
If Application.Version <> "11.0" Then
MsgBox "Pls open the file in Excel 2003!"
ThisWorkbook.Close
Exit Sub
Else
GoTo goooo:
End If
goooo:
p45cal
01-19-2011, 10:06 AM
Else
Goto goooo:
not necessary!
mancubus
01-19-2011, 10:07 AM
Perhaps:Private Sub Workbook_Open()
If Not Application.Version = "11.0" Then
MsgBox "Please only open this file in Excel 2003"
ThisWorkbook.Close
End If
End Sub
but of course, this won't stop people disabling macros.
i was ih thread so did not see your reply. so wasted my time for googling. :banghead:
this helps me force users enable macros.
http://www.vbaexpress.com/kb/getarticle.php?kb_id=379
mancubus
01-19-2011, 10:09 AM
Else
Goto goooo:
not necessary!
thx again.
should i also delete "Exit Sub" line.
p45cal
01-19-2011, 10:14 AM
Not sure! Try it!
mancubus
01-19-2011, 10:19 AM
Not sure! Try it!
deleted and no problem. file not opened in 2007. :thumb
thanks. :beerchug:
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.