Home |
Search |
Today's Posts |
#9
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Dave
Thanks - looks what I'm looking for! I'l try this asap. :-) Regards On 18 Sep., 18:06, Gord Dibben <gorddibbATshawDOTca wrote: Thanks for jumping in Dave. Gord On Fri, 18 Sep 2009 07:13:18 -0500, Dave Peterson wrote: I'm not sure what you're doing... But one way you could prevent the user from using that instance of excel is to open it via code and hide the application. If the application has to be visible, you could use an application event that counts the number of existing workbooks are open and won't let the user open another one. You can read more about application events at Chip Pearson's site: http://www.cpearson.com/excel/AppEvent.aspx All this would go into the ThisWorkbook module of your workbook. Option Explicit Public WithEvents xlApp As Excel.Application Private Sub Workbook_Open() * *Set xlApp = Application * *If xlApp.Workbooks.Count 1 Then * * * *MsgBox "This workbook cannot be opened if other " _ * * * * * * * & "workbooks are already opened" * * * *Me.Close savechanges:=False * *End If End Sub Private Sub Workbook_Close() * *Set xlApp = Nothing End Sub Private Sub xlApp_NewWorkbook(ByVal Wb As Workbook) * *If xlApp.Workbooks.Count 1 Then * * * *Wb.Close savechanges:=False * * * *MsgBox "Can't create a new workbook now!" * *End If End Sub Private Sub xlApp_WorkbookOpen(ByVal Wb As Workbook) * *If xlApp.Workbooks.Count 1 Then * * * *Wb.Close savechanges:=False * * * *MsgBox "Can't open a new workbook now!" * *End If End Sub These events will only work if the user has enabled macros and has not disabled events. Leon wrote: Hi I have a workboook which is updated every minute by using the ontime facility. It works fine when user not have any other workbook open in the same intance of Excel. How do I prevent user from open another workbook in the particular instance containing the workbook with autoupdate function (ontime) 1) when user tries to open another workbook via the open menu 2) when user dobbleclick on an xls file Regards- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Prevent multiple instances in Excel 2007 | Excel Discussion (Misc queries) | |||
Multiple Instance of appliction | Excel Discussion (Misc queries) | |||
How to open excel workbooks in SAME instance of Excel | Excel Discussion (Misc queries) | |||
HOW CAN I PREVENT EXCEL FILES FROM BEING DELETED OR PREVENT TRASH | Excel Discussion (Misc queries) | |||
Testing same cell across multiple sheets for a string and counting each instance? | Excel Worksheet Functions |