Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Files with VBA Macros Using same Shortcut Key

Status
Not open for further replies.

BruceMutton

Geotechnical
Sep 4, 2001
15
I have multiple simultaneously open files that have similar VBA code, and use identical shortcut keys, Ctrl+shift+V in this case. The problem is that excel97 & excel2000 does not seem to recognise more than one shortcut key allocation, and my attempt below to get each file to stamp its own shortcut key does not solve the problem, although the .MacroOptions method appears to work in every other respect.

Any clues to a solution out there?


Code:
'This code resides in ThisWorkbook CodeModules 
Private Sub Workbook_Activate() 
  Call MacroShortCutKeyOverRideSetup 
End Sub 
Private Sub MacroShortCutKeyOverRideSetup() 

 'Set up for activation of Outline Macro shortcut keys & UI dialog 
 'Hopefully ensures that other workbooks do not have  control of this key, but it does not have that effect!? 
 MsgBox "About to set Vert Macro shorcut", vbOKOnly, Me.Name 

'Vert Comb* outline
Application.MacroOptions
_
Macro:="'" & Me.Name & "'!ThisWorkbook.ToggleVertOutline", _
Description:="Ctrl+shift+V " & String(1, 10) & _
"Toggles vertical outline of ActiveSheet " & String(1, 10) & _
"Will act only on THISWorkbook", _
HasShortcutKey:=True, _
ShortcutKey:="V", _
StatusBar:="Toggles vertical outline of ActiveSheet "
Code:
End Sub 

Sub ToggleVertOutline()
'Any code in this proceedure, but I've left my original code as an example
Code:
'Toggle outline for CiRCSTRess RCDesign Workbook 
'Assumes only two levels of outline, 1 and 2 
'Mostly seems to work if used on VBA created outlines 
'Called from User Interface Ctrl+shift+V 
'Created by Bruce Mutton 030102 
'Edited by 

If LCase(Left(ActiveSheet.CodeName, ) <> &quot;rcdesign&quot; Then Exit Sub 
With ActiveSheet 
If .Rows(10).Hidden Then 
.Outline.ShowLevels RowLevels:=2 'rows expanded 
Else 
.Outline.ShowLevels RowLevels:=1 'rows collapsed 
End If 
End With 'ActiveSheet 
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor