View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default excel 2000 workbook.activate not 100% reliable with alt+tab

My suggestion was to let the menus appear, but block the execution if you're not
in a correct workbook.

Option Explicit
Sub testme()
If LCase(ActiveWorkbook.Path) < "c:\templates\admin" Then
Beep
MsgBox "Cannot be used on this workbook"
Exit Sub
End If
'your real code here
End Sub

But since you're overwriting existing functions, you'd have to do more. You'd
actually have to execute the equivalent function in your code.

for your save replacement:

Option Explicit
Sub testme()
If LCase(ActiveWorkbook.Path) < "c:\templates\admin" Then
ActiveWorkbook.Save
End If
'your original code here
End Sub

I think the suggestion is simple--but the implementation may be difficult.



Gavin Frayne wrote:

Hi Dave,

I really appreciate your help, but I'm not sure if I understand how your
suggestion can help me. Let me try to be as clear as possible about what I
wish to achieve:

File 1: c:\templates\admin\invoice.xls
File 2: c:\user\anything.xls

When I open invoice.xls I want my menu's to appear. Among others, my menu's
overwrite the standard save, save as and paste commands.

Now, while I have invoice.xls open on my desktop, I want to be able to open
c:\user\anything.xls and the menu's must not appear.
This work perfectly when I use the mouse.
Two things go wrong when I use Alt+Tab:
1. When I switch from invoice.xls to anything.xls, the deactivate event is
not triggered and my menus are not unloaded.
2. When I switch anything.xls to invoice.xls, the activate event is not
triggerd and my menus do not load.

The file anything.xls represents hundreds of files from individual users on
the network. I cannot place a macro in the open event of each of these to
check for a certain parameter before loading the menu. Even if this was
possible, it still wouldn't help me, because anything.xls would then be
loaded without a menu, and when I Alt+Tab back to invoice.xls, the activate
event is not fired and the menu's are not loaded.

If I misinterpreted your suggestion, could you please be a little more clear
about you mean...

Thanks and regards,
Gavin

<<snipped

--

Dave Peterson