PDA

View Full Version : How to disable the selection of Workbook



gopi09_m
05-19-2008, 10:08 AM
Hi,

I have a macro in WorkBook1.xls ,which opens the WorkBook2.xls.Macro in WorkBook1.xls process the data in WorkBook2.xls.
My requirement is to not let the user select WorkBook1.xls ,it means while macro is going on when i click the WorkBook1.xls it should not get selected.
And also when user manually closes the WorkBook2.xls then the WorkBook1.xls should be enabled automatically.

Is that possbile to implement these two things ?

Regards,
Krrishna

Bob Phillips
05-19-2008, 10:31 AM
Make workbook1 an addin, they won't see it then.

Simon Lloyd
05-19-2008, 11:18 AM
Bob i think the Op wants the workbook visible when the macro isn't running or WB2 is closed. Gopi maybe you can use this line at the start of the macro:

Windows("Workbook1.xls").Visible = False
where workbook1 is the name of your workbook

gopi09_m
05-19-2008, 07:19 PM
if i use the statment Windows("Workbook1.xls").Visible = False ,and when user closes WorkBook2.xls then how should i catch that event of workbook_close to make Windows("Workbook1.xls").Visible = true?

Simon Lloyd
05-19-2008, 08:13 PM
Put this in workbook 2 Thisworkbook module

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Windows("Workbook1.xls").Visible = True
End Sub

malik641
05-19-2008, 08:20 PM
Good ol' google. This works for the WHOLE app, though. But you may find it useful.

application.Interactive = false Don't forget to set it back to True