We are aware of the recently disclosed PHP2Shell vulnerabilities (CVE-2026-109618 and CVE-2026-109619) and can confirm ERStudio is not impacted by these vulnerabilities.
ER/スタジオロゴ
ER/スタジオロゴ
ホーム > リソースセンター > Shortcuts: a macro to rule them all

Shortcuts: a macro to rule them all

In this post, I’ll share a script which lets you add shortcuts to macros that you may want to quickly access from various places in ER/Studio データアーキテクト.

Usually, you would access the macros from the Macro tab of the Data Model Explorer:

Macro tab of the Data Model Explorer

Nevertheless, ER/Studio データアーキテクト can be configured with a quick access to your preferred macros through a right-click context menu on your objects of your models.

Normally, you would use the Add/Remove Macros dialog box to configure it:

Add/Remove Macros dialog box

However, the script below will allow you to quickly manage your macro shortcuts and associate them with any existing macros, including those in any subfolders beneath your Macros Directory.

Here are the various places within ER/Studio データアーキテクト where you can find the macro shortcuts:

  • Macro tab (Ribbon)
  • Diagram (Context menu)
  • Entity (Context menu)
  • Relationship (Context menu)
  • Shape (Context menu)
  • Business Data Object (Context menu)
  • View (Context menu)
Examples:
Ribbon
Context menu

When the macro to create these shortcuts is run, its interface will display the following:

  • on the left (Selected macros) is the list of macros that are made available to the context menu
  • on the right (Available macros) are the available macros from your Macros Directory
wMacro Shortcuts UI

スクリプト

Below is the sample macro script:

'#Language "WWB-COM"
''MACRO TITLE: Macro Shortcuts
' MACRO VERSION: 1.1
'This macro allows to select the Macro Shortcuts you want to use
' 	by object type
' https://docwiki.embarcadero.com/ERStudioDA/en/Adding_Macros_to_GUI_Modeling_Menus
'
' Release notes
' 1.1 Buttons to move the shortcuts added
' 		Select current macro (show this file in the macro UI)
' 1.0 Initial version
'---------------------------------------------------------------------------

オプション 明示的

コンスト TITLE$ = "wMacro Shortcuts"
コンスト NONE$ = "<None>" ' Label for empty values

薄暗い laFolders$()
薄暗い laFiles$()
薄暗い laMacros$()
薄暗い laMenuKey$()
薄暗い laMenuLabel$()
薄暗い sMacrosDirectory$

サブ メイン

	薄暗い iLoop%

	Debug.クリア

	ReDim laMenuKey(6)
	ReDim laMenuLabel(6)

	laMenuKey  (0) = "DiagramMenuMacros"
	laMenuLabel(0) = "Diagram Menu"
	laMenuKey  (1) = "EntityMenuMacros"
	laMenuLabel(1) = "Entity Menu"
	laMenuKey  (2) = "MainMenuMacros"
	laMenuLabel(2) = "Main Menu"
	laMenuKey  (3) = "RelMenuMacros"
	laMenuLabel(3) = "Relationship Menu"
	laMenuKey  (4) = "ShapeMenuMacros"
	laMenuLabel(4) = "Shape Menu"
	laMenuKey  (5) = "SubjectAreaMenuMacros"
	laMenuLabel(5) = "Business Data Object Menu"
	laMenuKey  (6) = "ViewMenuMacros"
	laMenuLabel(6) = "View Menu"

	' Get the selected macros
	sMacrosDirectory = GetMacrosDirectory()

	ReDim laMacros(0 へ 9)

	iLoop = 0
	ReDim laFolders(0 へ 99)
	laFolders(0) = "\"

	' Get the different folders
	AddSubFolders(sMacrosDirectory, iLoop)

	ReDim Preserve laFolders(0 へ iLoop)

	について iLoop = 1 へ UBound(laFolders)
		
		laFolders(iLoop) = Replace(laFolders(iLoop), sMacrosDirectory, "",,1)

	次のページ iLoop

	開始 Dialog UserDialog 970,315,TITLE,.DialogFunc ' %grid:10,7,1,1
		GroupBox 10,7,500,273,"Selected macros",.gbSelectedMacros
		Text 20,28,90,14,"Object type:",.tObjectType
		DropListBox 20,42,480,70,laMenuLabel(),.dlbMenu
		Text 20,63,90,14,"Macros:",.tMacros
		ListBox 20,77,480,126,laMacros(),.lbMacros
		Text 20,210,480,14,"",.tMacro,1
		PushButton 20,224,480,21,"Delete current shortcut",.pbDelete
		PushButton 20,252,230,21,"Move up",.pbMoveUp
		PushButton 270,252,230,21,"Move down",.pbMoveDown
		GroupBox 530,7,430,273,"Available macros",.gbAvailableMacros
		Text 540,28,90,14,"Folders:",.tFolders
		DropListBox 540,42,410,70,laFolders(),.dlbFolder,2
		Text 540,63,90,14,"Files:",.tFiles
		ListBox 540,77,410,140,laFiles(),.lbFiles,1
		PushButton 540,224,410,21,"Add current macro to selected shortcut",.pbAdd
		PushButton 540,252,410,21,"Select current macro",.pbCurrentMacro
		OKButton 450,287,90,21
	終了 ダイアログ

	薄暗い dlg として UserDialog

	dlg.dlbMenu = 5

	もし ダイアログ(dlg) = -1 では
		
		もし (dlg.dlbFolder <> -1) そして (dlg.lbFiles <> -1) では
			
			デバッグ。.プリント "file: " & sMacrosDirectory & laFolders(dlg.dlbFolder) & IIf(dlg.dlbFolder > 0, "\", "") & laFiles(dlg.lbFiles)

		その他
			
			デバッグ。.プリント "No file selected"

		終了 もし

	終了 もし

終了 サブ

Rem 詳細は DialogFunc のヘルプを参照。.
プライベート 機能 DialogFunc(DlgItem として ストリング, Action として 整数, SuppValue として PortInt) として ブーリアン
	
	薄暗い iLoop%

	Select Case Action
	Case 1 ' Dialog box initialization

		DlgEnable "pbAdd", False
		DlgEnable "pbDelete", False
		DlgEnable "pbMoveUp", False
		DlgEnable "pbMoveDown", False
		DlgEnable "pbCurrentMacro", Left(CurrentMacro, Len(sMacrosDirectory)) = sMacrosDirectory

		RefreshMacros
		RefreshFiles
'		DlgEnable "OK", (UBound(laFiles) <> -1)

	Case 2 '値の変更またはボタンの押下
		
		Rem DialogFunc = True ' Prevent button press from closing the dialog box
		Select Case DlgItem
		Case "dlbFolder"
			
			RefreshFiles
			RefreshAddButton
			DialogFunc = 真

		Case "dlbMenu"
			
			RefreshMacros
			DialogFunc = 真

		Case "lbFiles"
			
			RefreshAddButton
			Debug.プリント DlgValue("lbFiles") & "--> " & sMacrosDirectory & laFolders(DlgValue "dlbFolder") & IIf((DlgValue "dlbFolder") > 0, "\", "") & laFiles(DlgValue "lbFiles")

			DialogFunc = 真

		Case "lbMacros"
			
			RefreshAddButton
			RefreshShortcutsButtons
			SelectMacro
			DlgText("tMacro", laMacros(DlgValue "lbMacros"))
			Debug.プリント DlgValue("lbMacros") & "--> " & laMacros(DlgValue "lbMacros")

			DialogFunc = 真

		Case "pbAdd"
			
			UpdateMacroShortcut(DlgValue("lbMacros"), sMacrosDirectory & laFolders(DlgValue "dlbFolder") & IIf((DlgValue "dlbFolder") > 0, "\", "") & laFiles(DlgValue "lbFiles"))
			Debug.プリント sMacrosDirectory & laFolders(DlgValue "dlbFolder") & IIf((DlgValue "dlbFolder") > 0, "\", "") & laFiles(DlgValue "lbFiles") & "--> " & DlgValue "lbMacros"

			DialogFunc = 真

		Case "pbDelete"
			
			DeleteMacroShortcut(DlgValue("lbMacros"))
			Debug.プリント "--> " & DlgValue "lbMacros"

			DialogFunc = 真

		Case "pbMoveUp"
			
			MoveShortcut(DlgValue("lbMacros"), 真)
			Debug.プリント "Move up: " & DlgValue "lbMacros"

			DialogFunc = 真

		Case "pbMoveDown"
			
			MoveShortcut(DlgValue("lbMacros"), False)
			Debug.プリント "Move down: " & DlgValue "lbMacros"

			DialogFunc = 真

		Case "pbCurrentMacro"
			
			SelectMacro(CurrentMacro)
			Debug.プリント "Selecting current macro: " & TITLE

			DialogFunc = 真

		終了 Select

	Case 3 ' TextBox or ComboBox text changed
	Case 4 ' Focus changed
	Case 5 ' Idle
		Rem Wait .1 : DialogFunc = True ' Continue getting idle actions
	Case 6 ' Function key
	終了 Select

End 機能

プライベート 機能 GetMacrosDirectory として ストリング
	
	GetMacrosDirectory = オブジェクトの作成("WScript.Shell").RegRead(DiagramManager.GetRegistryKey & "\Application\MacroDirectory")

終了 機能

プライベート サブ AddSubFolders(sRoot$, ByRef index%)
	
	薄暗い F$
	薄暗い iFrom%, iTo%, iLoop%

	iFrom = index + 1

	' Add the "root folders"
	F$ = Dir$(sRoot & "\*.", vbDirectory)
	While (F$ <> "") そして (index < UBound(laFolders))
		もし (F$ <> ".") そして (F$ <> "..") では
			index = index + 1
			laFolders(index) = sRoot & "\" & F$
			Debug.プリント F$
		終了 もし
		F$ = Dir$()
	Wend

	iTo = index

	について iLoop = iFrom へ iTo

		AddSubFolders(laFolders(iLoop), index)

	次のページ iLoop

終了 サブ

プライベート サブ LoadFiles(sFolder$)

	薄暗い F$, index%

	index = 0
	ReDim laFiles(0 へ 99)

	' Add the macro files
	F$ = Dir$(sFolder & "\*.bas")
	While (F$ <> "")
		もし (F$ <> ".") そして (F$ <> "..") では
			laFiles(index) = F$
			index = index + 1
			Debug.プリント Chr(9) & F$
		終了 もし
		F$ = Dir$()
	Wend

	ReDim Preserve laFiles(0 へ (index - 1))

終了 サブ

プライベート サブ RefreshFiles()
	
	LoadFiles(sMacrosDirectory & laFolders(DlgValue "dlbFolder"))
	DlgListBoxArray("lbFiles", laFiles)

終了 サブ

プライベート サブ RefreshMacros()
	
	薄暗い sh
	薄暗い iLoop%
	薄暗い sMacro$, sRK$, sKey$

	もし DlgValue("dlbMenu") <> -1 では
		
		セット sh = オブジェクトの作成("WScript.Shell")
		sRK = DiagramManager.GetRegistryKey & "\" & laMenuKey(DlgValue("dlbMenu")) & "\"
	
		について iLoop = 1 へ 10

			オン エラー GoTo Errors_Handler
			sKey = sRK & "Macro" & iLoop
			sMacro = sh.RegRead(sKey)
			もし sMacro <> "" では
	
				laMacros(iLoop - 1) = Replace(sMacro, sMacrosDirectory, "",,1)
	
			その他
				
				laMacros(iLoop - 1) = NONE
	
			終了 もし
	
		次のページ iLoop
	
		DlgListBoxArray("lbMacros", laMacros)
		RefreshAddButton

	終了 もし

	出口 サブ

Errors_Handler:

	もし エラー.Number = -2147024894 では

		もし WriteMacroShortcut(sKey, "") では
			
			sMacro = NONE

			エラー.クリア
			Resume 次のページ

		その他
			
			デバッグ。.プリント "Can't access the usual registry key!"

			出口 All

		終了 もし

	終了 もし

終了 サブ

プライベート 機能 WriteMacroShortcut(sKey$, sMacro$) として ブーリアン

	薄暗い sh

	セット sh = オブジェクトの作成("WScript.Shell")

	オン エラー GoTo Errors_Handler

	sh.RegWrite(sKey, sMacro)
	WriteMacroShortcut = 真

	出口 機能

Errors_Handler:

	WriteMacroShortcut = False
	Resume Next

End 機能

プライベート サブ RefreshAddButton()
	
	DlgEnable "pbAdd", (DlgValue("lbMacros") <> -1) そして (DlgValue("lbFiles") <> -1)
	DlgText("tMacro", "")

終了 サブ

プライベート サブ RefreshShortcutsButtons()

	オン エラー GoTo Errors_Handler

	薄暗い bState として ブーリアン

	bState = (DlgValue("lbMacros") <> -1)

	DlgEnable "pbDelete", bState そして (laMacros(DlgValue("lbMacros")) <> NONE)
	DlgEnable "pbMoveUp", (DlgValue("lbMacros") > 0)
	DlgEnable "pbMoveDown", bState そして (DlgValue("lbMacros") < 9)

Errors_Handler:

	Debug.プリント DlgValue("lbMacros")
	Resume Next

End サブ

プライベート 機能 UpdateMacroShortcut(iMacroIndex%, sMacro$) として ブーリアン
	
	UpdateMacroShortcut = WriteMacroShortcut(DiagramManager.GetRegistryKey & "\" & laMenuKey(DlgValue("dlbMenu")) & "\Macro" & (iMacroIndex + 1), sMacro)
	laMacros(iMacroIndex) = IIf(sMacro = "", NONE, Replace(sMacro, sMacrosDirectory, "",,1))
	DlgListBoxArray("lbMacros", laMacros)
	DlgValue "lbMacros", iMacroIndex

	Debug.プリント "Macro Shortcut " & (iMacroIndex + 1) & " has been " & IIf(sMacro = "", "dele", "upda") & "ted!"

	RefreshAddButton
	RefreshShortcutsButtons
	
終了 機能

プライベート 機能 DeleteMacroShortcut(iMacroIndex%) として ブーリアン
	
	DeleteMacroShortcut = WriteMacroShortcut(DiagramManager.GetRegistryKey & "\" & laMenuKey(DlgValue("dlbMenu")) & "\Macro" & (iMacroIndex + 1), "")
	laMacros(iMacroIndex) = NONE
	DlgListBoxArray("lbMacros", laMacros)
	DlgValue "lbMacros", iMacroIndex

	Debug.プリント "Macro Shortcut " & (iMacroIndex + 1) & " has been deleted!"

	RefreshAddButton
	DlgEnable "pbDelete", False
	
終了 機能

プライベート サブ SelectMacro(Optional sMacro$ = "")
	
	薄暗い sPath$
	薄暗い iIndex%, iLoop%

	もし sMacro = "" では
		
		sMacro = laMacros(DlgValue "lbMacros")

	その他
		
		sMacro = Replace(sMacro, sMacrosDirectory, "",, 1)

	終了 もし

	デバッグ。.プリント "Current macro: " & sMacro

	もし sMacro <> NONE では
		
		iIndex = InStrRev(sMacro, "\")
	
		もし iIndex > 0 では
			
			sPath = Left(sMacro, iIndex - 1)
			sMacro = Replace(sMacro, sPath & "\", "",, 1)
	
			Debug.プリント "Path: " & sPath
			Debug.プリント "Macro: " & sMacro

			について iIndex = LBound(laFolders) へ UBound(laFolders)
				
				もし LCase(laFolders(iIndex)) = LCase(sPath) では
					
					DlgValue("dlbFolder", iIndex)
					RefreshFiles

					について iLoop = LBound(laFiles) へ UBound(laFiles)
						
						もし LCase(laFiles(iLoop)) = LCase(sMacro) では
							
							DlgValue("lbFiles", iLoop)
							出口 について

						終了 もし
		
					次のページ iLoop

					出口 について

				終了 もし

			次のページ iIndex
	
		終了 もし

	終了 もし

	RefreshAddButton

終了 サブ

プライベート サブ MoveShortcut(iIndex%, bMoveUp として ブーリアン)
	
	薄暗い sValue$, iSibling%
	
	もし (iIndex >= 0) あるいは (iIndex <= 9) では
		
		' Up & 1st row
		もし bMoveUp そして (iIndex = 0) では
			
			出口 サブ

		終了 もし

		' Down & last row
		もし (Not bMoveUp) そして (iIndex = 9) では
			
			出口 サブ

		終了 もし

		' The index of the shortcut to switch
		iSibling = IIf(bMoveUp, iIndex - 1, iIndex + 1)
		' Value of the current shortcut
		sValue = laMacros(iIndex)
		' Switch shortcuts
		laMacros(iIndex) = laMacros(iSibling)
		laMacros(iSibling) = sValue

		' Update the Windows Registry
		もし laMacros(iIndex) <> NONE では
			
			UpdateMacroShortcut(iIndex, IIf(Left(laMacros(iIndex), 1) = "\", sMacrosDirectory, "") & laMacros(iIndex))

		その他
			
			WriteMacroShortcut(DiagramManager.GetRegistryKey & "\" & laMenuKey(DlgValue("dlbMenu")) & "\Macro" & (iIndex + 1), "")

		終了 もし

		もし laMacros(iSibling) <> NONE では
			
			UpdateMacroShortcut(iSibling, IIf(Left(laMacros(iSibling), 1) = "\", sMacrosDirectory, "") & laMacros(iSibling))

		その他
			
			WriteMacroShortcut(DiagramManager.GetRegistryKey & "\" & laMenuKey(DlgValue("dlbMenu")) & "\Macro" & (iSibling + 1), "")

		終了 もし

		DlgListBoxArray("lbMacros", laMacros)
		DlgValue "lbMacros", iSibling
		Debug.プリント "Shortcut moved from " & iIndex & " to " & iSibling

		RefreshShortcutsButtons

	終了 もし

終了 サブ

プライベート 機能 CurrentMacro$
	
	薄暗い sCurrentMacro$

	sCurrentMacro = Mid(CallersLine, 2, InStr(CallersLine, "|") - 2)

	もし Dir$(sCurrentMacro) <> "" では

		CurrentMacro = sCurrentMacro

	その他
		
		CurrentMacro = ""

	終了 もし

終了 機能

概要

In this post, we have supplied the above macro which helps to create right-click context menu shortcuts for your macros.

Programmatically, this script does the following

  • gets files from your hard drive
  • updates the Windows registry
  • uses different macro UI components

ボーナス

A ショートビデオ ER/Studio Data Architectでスクリプトからマクロを作成する方法を説明します:

著作権 © 2026 Idera, Inc.
Hi! Need help finding something?
ER/Studio
Sales questions and support links