Delphi Programming / Object Pascal
サイトのトップページへ リンクのページへ ロゴマーク
[掲載 2009年06月10日] [更新 2013年12月19日] エクセル操作フォームEx
   
エクセル操作フォームEx   参考コード類
各種ダイアログの表示
動作確認等 Windows 7 U64(SP1) + Delphi XE Pro + Excel 2010







各種ダイアログの表示


リストボックスで選択したダイアログを表示します.Excel 2007 VBA のヘルプの内容をリストにしたものです.リストボックスの表示文字列もヘルプの記述通りとなっています.筆者はほんど動作確認をしていませんのでご了承ください.少なくても,エクセルではどんなダイアログが用意されているかの参考にはなるでしょう.

エクセルのダイアログは,Excel 2007 よりも前のバージョンでは全てモーダル表示 (ダイアログを閉じるまでエクセル本体は操作できない) でした.Excel 2007 ではダイアログによってはモードレスで表示するものがあります.エクセル操作フォームExで表示した場合はダイアログを閉じるまではフォームを操作できないようにしていますが,モーダル表示ということではありません.
また Excel と OS のバージョンによっては,ダイアログを表示すると,ダイアログの残像が画面に残り,白く抜けてしまうことがあります.この現象は,筆者の環境の Windows 7 + Excel 2007 では発生していません.

このダイアログのリスト (ListBox の Items) のコードは,ヘルプの内容をテキストファイルにした後,必要な部分を読み出しながら TStringList に該当部分を格納して作成したものです.


図1
ダイアログのリスト
  • ButtonとListboxを配置しておく
図2
セルの書式設定ダイアログ

リスト1
//=============================================================================
//  フォームを表示する時に組み込みダイアログのリストを作成
//  Excel 2007 VABのヘルプをコピーしたテキストから作成
//=============================================================================
procedure TplExcelFormEx1.FormShow(Sender: TObject);
begin
  ListBox1.Items.Clear;
  with ListBox1.Items do begin
     BeginUpdate;
     AddObject( 'ウィンドウの選択',
              TObject( xlDialogActivate ));
     AddObject( 'セルの書式設定 (フォント)',
              TObject( xlDialogActiveCellFont ));
     AddObject( 'ユーザー設定のグラフ種類の追加',
              TObject( xlDialogAddChartAutoformat ));
     AddObject( 'アドイン',
              TObject( xlDialogAddinManager ));
     AddObject( 'セルの書式設定 (配置)',
              TObject( xlDialogAlignment ));
     AddObject( '名前の引用',
              TObject( xlDialogApplyNames ));
     AddObject( 'スタイル',
              TObject( xlDialogApplyStyle ));
     AddObject( '移動(アプリケーション)',
              TObject( xlDialogAppMove ));
     AddObject( '送信',
              TObject( xlDialogAppSize ));
     AddObject( 'ウィンドウの整列',
              TObject( xlDialogArrangeAll ));
     AddObject( 'オブジェクトへの登録',
              TObject( xlDialogAssignToObject ));
     AddObject( 'ツールに割り当て',
              TObject( xlDialogAssignToTool ));
     AddObject( '文字の追加',
              TObject( xlDialogAttachText ));
     AddObject( 'ブックへのツールバーの登録',
              TObject( xlDialogAttachToolbars ));
     AddObject( 'オートコレクト (オートコレクト)',
              TObject( xlDialogAutoCorrect ));
     AddObject( '軸',
              TObject( xlDialogAxes ));
     AddObject( 'セルの書式設定 (罫線)',
              TObject( xlDialogBorder ));
     AddObject( '計算方法の設定',
              TObject( xlDialogCalculation ));
     AddObject( 'セルの書式設定 (保護)',
              TObject( xlDialogCellProtection ));
     AddObject( 'リンクの変更',
              TObject( xlDialogChangeLink ));
     AddObject( 'グラフ追加データ',
              TObject( xlDialogChartAddData ));
     AddObject( 'グラフの場所',
              TObject( xlDialogChartLocation ));
     AddObject( 'グラフ オプション データ ラベル',
              TObject( xlDialogChartOptionsDataLabels ));
     AddObject( 'グラフ オプション データ テーブル',
              TObject( xlDialogChartOptionsDataTable ));
     AddObject( 'グラフの元データ',
              TObject( xlDialogChartSourceData ));
     AddObject( 'グラフ トレンド',
              TObject( xlDialogChartTrend ));
     AddObject( 'グラフの種類',
              TObject( xlDialogChartType ));
     AddObject( 'グラフ ウィザード',
              TObject( xlDialogChartWizard ));
     AddObject( 'チェック ボックスのプロパティ',
              TObject( xlDialogCheckboxProperties ));
     AddObject( '消去',
              TObject( xlDialogClear ));
     AddObject( 'オプション (色)',
              TObject( xlDialogColorPalette ));
     AddObject( '列幅',
              TObject( xlDialogColumnWidth ));
     AddObject( '複合',
              TObject( xlDialogCombination ));
     AddObject( '条件付き書式の設定',
              TObject( xlDialogConditionalFormatting ));
     AddObject( '統合の設定',
              TObject( xlDialogConsolidate ));
     AddObject( 'グラフのコピー',
              TObject( xlDialogCopyChart ));
     AddObject( '図のコピー',
              TObject( xlDialogCopyPicture ));
     AddObject( '名前の作成',
              TObject( xlDialogCreateNames ));
     AddObject( '発行側の作成',
              TObject( xlDialogCreatePublisher ));
     AddObject( 'ユーザー設定 (オプション)',
              TObject( xlDialogCustomizeToolbar ));
     AddObject( 'ユーザー設定のビュー',
              TObject( xlDialogCustomViews ));
     AddObject( 'データの削除',
              TObject( xlDialogDataDelete ));
     AddObject( 'データ ラベル',
              TObject( xlDialogDataLabel ));
     AddObject( '連続データ',
              TObject( xlDialogDataSeries ));
     AddObject( 'データの入力規則 (設定)',
              TObject( xlDialogDataValidation ));
     AddObject( '名前の定義',
              TObject( xlDialogDefineName ));
     AddObject( 'スタイル',
              TObject( xlDialogDefineStyle ));
     AddObject( 'セルの書式設定 (表示形式)',
              TObject( xlDialogDeleteFormat ));
     AddObject( '名前の定義',
              TObject( xlDialogDeleteName ));
     AddObject( 'グループ化',
              TObject( xlDialogDemote ));
     AddObject( '画面設定',
              TObject( xlDialogDisplay ));
     AddObject( '編集ボックスのプロパティ',
              TObject( xlDialogEditboxProperties ));
     AddObject( '色の編集',
              TObject( xlDialogEditColor ));
     AddObject( '削除',
              TObject( xlDialogEditDelete ));
     AddObject( 'エディション オプション',
              TObject( xlDialogEditionOptions ));
     AddObject( '系列の編集',
              TObject( xlDialogEditSeries ));
     AddObject( 'Errorbar X',
              TObject( xlDialogErrorbarX ));
     AddObject( 'Errorbar Y',
              TObject( xlDialogErrorbarY ));
     AddObject( '外部データのプロパティ',
              TObject( xlDialogExternalDataProperties ));
     AddObject( '抽出',
              TObject( xlDialogExtract ));
     AddObject( 'ファイルの削除',
              TObject( xlDialogFileDelete ));
     AddObject( 'ブックの共有 (編集)',
              TObject( xlDialogFileSharing ));
     AddObject( 'グループの入力',
              TObject( xlDialogFillGroup ));
     AddObject( 'ワークグループの入力',
              TObject( xlDialogFillWorkgroup ));
     AddObject( 'オートフィルタ',
              TObject( xlDialogFilter ));
     AddObject( 'フィルタ オプションの設定',
              TObject( xlDialogFilterAdvanced ));
     AddObject( 'ファイルを開く',
              TObject( xlDialogFindFile ));
     AddObject( 'フォントの設定',
              TObject( xlDialogFont ));
     AddObject( 'セルの書式設定 (フォント)',
              TObject( xlDialogFontProperties ));
     AddObject( 'オートフォーマット',
              TObject( xlDialogFormatAuto ));
     AddObject( 'グラフの書式設定',
              TObject( xlDialogFormatChart ));
     AddObject( 'グラフの種類',
              TObject( xlDialogFormatCharttype ));
     AddObject( 'フォントの設定',
              TObject( xlDialogFormatFont ));
     AddObject( '凡例の書式設定',
              TObject( xlDialogFormatLegend ));
     AddObject( 'メイングラフ/重ね合わせグラフ',
              TObject( xlDialogFormatMain ));
     AddObject( '移動の書式設定',
              TObject( xlDialogFormatMove ));
     AddObject( 'セルの書式設定 (表示形式)',
              TObject( xlDialogFormatNumber ));
     AddObject( '重ね合わせグラフの設定',
              TObject( xlDialogFormatOverlay ));
     AddObject( 'サイズの書式設定',
              TObject( xlDialogFormatSize ));
     AddObject( '文字書式',
              TObject( xlDialogFormatText ));
     AddObject( '検索',
              TObject( xlDialogFormulaFind ));
     AddObject( 'ジャンプ',
              TObject( xlDialogFormulaGoto ));
     AddObject( '置換',
              TObject( xlDialogFormulaReplace ));
     AddObject( '関数の挿入',
              TObject( xlDialogFunctionWizard ));
     AddObject( 'オートフォーマット (3-D 面)',
              TObject( xlDialogGallery3dArea ));
     AddObject( 'オートフォーマット (横棒)',
              TObject( xlDialogGallery3dBar ));
     AddObject( 'オートフォーマット (3-D 縦棒)',
              TObject( xlDialogGallery3dColumn ));
     AddObject( 'オートフォーマット (3-D 折れ線)',
              TObject( xlDialogGallery3dLine ));
     AddObject( 'オートフォーマット (3-D 円)',
              TObject( xlDialogGallery3dPie ));
     AddObject( 'オートフォーマット (等高線)',
              TObject( xlDialogGallery3dSurface ));
     AddObject( 'オートフォーマット (面)',
              TObject( xlDialogGalleryArea ));
     AddObject( 'オートフォーマット (横棒)',
              TObject( xlDialogGalleryBar ));
     AddObject( 'オートフォーマット (縦棒)',
              TObject( xlDialogGalleryColumn ));
     AddObject( 'オートフォーマット (フォーマットの種類)',
              TObject( xlDialogGalleryCustom ));
     AddObject( 'オートフォーマット (ドーナッツ)',
              TObject( xlDialogGalleryDoughnut ));
     AddObject( 'オートフォーマット (折れ線)',
              TObject( xlDialogGalleryLine ));
     AddObject( 'オートフォーマット (円)',
              TObject( xlDialogGalleryPie ));
     AddObject( 'オートフォーマット (レーダー)',
              TObject( xlDialogGalleryRadar ));
     AddObject( 'オートフォーマット (散布図)',
              TObject( xlDialogGalleryScatter ));
     AddObject( 'ゴール シーク',
              TObject( xlDialogGoalSeek ));
     AddObject( 'グラフ オプション (目盛線)',
              TObject( xlDialogGridlines ));
     AddObject( 'テキスト ファイルのインポート',
              TObject( xlDialogImportTextFile ));
     AddObject( 'セルの挿入',
              TObject( xlDialogInsert ));
     AddObject( 'ハイパーリンクの挿入',
              TObject( xlDialogInsertHyperlink ));
     AddObject( 'ラベル範囲',
              TObject( xlDialogInsertNameLabel ));
     AddObject( 'オブジェクトの挿入 (新規作成)',
              TObject( xlDialogInsertObject ));
     AddObject( '図の挿入',
              TObject( xlDialogInsertPicture ));
     AddObject( 'タイトル/軸ラベルの挿入',
              TObject( xlDialogInsertTitle ));
     AddObject( 'ラベルのプロパティ',
              TObject( xlDialogLabelProperties ));
     AddObject( 'リスト ボックスのプロパティ',
              TObject( xlDialogListboxProperties ));
     AddObject( 'マクロ オプション',
              TObject( xlDialogMacroOptions ));
     AddObject( 'メール編集メーラー',
              TObject( xlDialogMailEditMailer ));
     AddObject( '回覧先',
              TObject( xlDialogMailLogon ));
     AddObject( '次の手紙の送信',
              TObject( xlDialogMailNextLetter ));
     AddObject( 'メイン グラフ',
              TObject( xlDialogMainChart ));
     AddObject( 'メイン グラフの種類',
              TObject( xlDialogMainChartType ));
     AddObject( 'メニュー エディタ',
              TObject( xlDialogMenuEditor ));
     AddObject( '移動',
              TObject( xlDialogMove ));
     AddObject( '新規作成 (標準)',
              TObject( xlDialogNew ));
     AddObject( '新しい Web クエリ',
              TObject( xlDialogNewWebQuery ));
     AddObject( 'コメントの挿入',
              TObject( xlDialogNote ));
     AddObject( 'オブジェクトのプロパティ',
              TObject( xlDialogObjectProperties ));
     AddObject( 'オブジェクトの保護',
              TObject( xlDialogObjectProtection ));
     AddObject( 'ファイルを開く',
              TObject( xlDialogOpen ));
     AddObject( 'リンク元を開く',
              TObject( xlDialogOpenLinks ));
     AddObject( 'メールを開く',
              TObject( xlDialogOpenMail ));
     AddObject( 'テキストを開く',
              TObject( xlDialogOpenText ));
     AddObject( 'オプション (計算方法)',
              TObject( xlDialogOptionsCalculation ));
     AddObject( 'オプション (グラフ)',
              TObject( xlDialogOptionsChart ));
     AddObject( 'オプション (編集)',
              TObject( xlDialogOptionsEdit ));
     AddObject( 'オプション (全般)',
              TObject( xlDialogOptionsGeneral ));
     AddObject( 'オプション (ユーザー設定リスト)',
              TObject( xlDialogOptionsListsAdd ));
     AddObject( 'オプション (インターナショナル)',
              TObject( xlDialogOptionsME ));
     AddObject( 'オプション (移行)',
              TObject( xlDialogOptionsTransition ));
     AddObject( 'オプション (表示)',
              TObject( xlDialogOptionsView ));
     AddObject( '設定',
              TObject( xlDialogOutline ));
     AddObject( '重ね合わせグラフ',
              TObject( xlDialogOverlay ));
     AddObject( 'グラフの種類の重ね合わせ',
              TObject( xlDialogOverlayChartType ));
     AddObject( 'ページ設定 (ページ)',
              TObject( xlDialogPageSetup ));
     AddObject( '区切り位置',
              TObject( xlDialogParse ));
     AddObject( '名前の貼り付け',
              TObject( xlDialogPasteNames ));
     AddObject( '形式を選択して貼り付け',
              TObject( xlDialogPasteSpecial ));
     AddObject( 'セルの書式設定 (パターン)',
              TObject( xlDialogPatterns ));
     AddObject( 'ふりがなの設定 (ふりがな)',
              TObject( xlDialogPhonetic ));
     AddObject( 'ピボット集計フィールド',
              TObject( xlDialogPivotCalculatedField ));
     AddObject( 'ピボット集計アイテム',
              TObject( xlDialogPivotCalculatedItem ));
     AddObject( 'ピボット クライアント サーバー セット',
              TObject( xlDialogPivotClientServerSet ));
     AddObject( 'ピボット フィールド グループ',
              TObject( xlDialogPivotFieldGroup ));
     AddObject( 'ピボット フィールド プロパティ',
              TObject( xlDialogPivotFieldProperties ));
     AddObject( 'ピボット フィールド グループ解除',
              TObject( xlDialogPivotFieldUngroup ));
     AddObject( 'ピボット表示ページ',
              TObject( xlDialogPivotShowPages ));
     AddObject( 'ピボット解決順序',
              TObject( xlDialogPivotSolveOrder ));
     AddObject( 'ピボットテーブル オプション',
              TObject( xlDialogPivotTableOptions ));
     AddObject( 'ピボットテーブル/ピボットグラフ ウィザード',
              TObject( xlDialogPivotTableWizard ));
     AddObject( '表示位置',
              TObject( xlDialogPlacement ));
     AddObject( '印刷',
              TObject( xlDialogPrint ));
     AddObject( 'プリンタの設定',
              TObject( xlDialogPrinterSetup ));
     AddObject( '印刷プレビュー',
              TObject( xlDialogPrintPreview ));
     AddObject( 'グループの解除',
              TObject( xlDialogPromote ));
     AddObject( 'プロパティ (ファイルの概要)',
              TObject( xlDialogProperties ));
     AddObject( 'シートの保護',
              TObject( xlDialogProtectDocument ));
     AddObject( '共有ブックの保護',
              TObject( xlDialogProtectSharing ));
     AddObject( 'Web ページとして発行',
              TObject( xlDialogPublishAsWebPage ));
     AddObject( 'プッシュ ボタンのプロパティ',
              TObject( xlDialogPushbuttonProperties ));
     AddObject( 'フォントの設定',
              TObject( xlDialogReplaceFont ));
     AddObject( '回覧先',
              TObject( xlDialogRoutingSlip ));
     AddObject( '行の高さ',
              TObject( xlDialogRowHeight ));
     AddObject( 'マクロ',
              TObject( xlDialogRun ));
     AddObject( '名前を付けて保存',
              TObject( xlDialogSaveAs ));
     AddObject( 'コピーを名前を付けて保存',
              TObject( xlDialogSaveCopyAs ));
     AddObject( '新しいオブジェクトの保存',
              TObject( xlDialogSaveNewObject ));
     AddObject( '名前を付けて保存',
              TObject( xlDialogSaveWorkbook ));
     AddObject( '作業状態の保存',
              TObject( xlDialogSaveWorkspace ));
     AddObject( '倍率',
              TObject( xlDialogScale ));
     AddObject( 'シナリオの追加',
              TObject( xlDialogScenarioAdd ));
     AddObject( 'シナリオの登録と管理',
              TObject( xlDialogScenarioCells ));
     AddObject( 'シナリオの追加',
              TObject( xlDialogScenarioEdit ));
     AddObject( 'シナリオのコピー',
              TObject( xlDialogScenarioMerge ));
     AddObject( 'シナリオの情報',
              TObject( xlDialogScenarioSummary ));
     AddObject( 'スクロール バーのプロパティ',
              TObject( xlDialogScrollbarProperties ));
     AddObject( '選択オプション',
              TObject( xlDialogSelectSpecial ));
     AddObject( 'メッセージ (HTML 形式)',
              TObject( xlDialogSendMail ));
     AddObject( '系列軸',
              TObject( xlDialogSeriesAxes ));
     AddObject( '系列オプション',
              TObject( xlDialogSeriesOptions ));
     AddObject( '系列の順序',
              TObject( xlDialogSeriesOrder ));
     AddObject( '系列の形状',
              TObject( xlDialogSeriesShape ));
     AddObject( '系列 X',
              TObject( xlDialogSeriesX ));
     AddObject( 'データ系列の書式設定 (名前/値)',
              TObject( xlDialogSeriesY ));
     AddObject( 'シートの背景',
              TObject( xlDialogSetBackgroundPicture ));
     AddObject( '印刷タイトルの設定',
              TObject( xlDialogSetPrintTitles ));
     AddObject( '更新状態の設定',
              TObject( xlDialogSetUpdateStatus ));
     AddObject( '詳細データの表示',
              TObject( xlDialogShowDetail ));
     AddObject( 'ユーザー設定 (オプション)',
              TObject( xlDialogShowToolbar ));
     AddObject( 'サイズ',
              TObject( xlDialogSize ));
     AddObject( '並べ替え',
              TObject( xlDialogSort ));
     AddObject( '並べ替え',
              TObject( xlDialogSortSpecial ));
     AddObject( '列の分割、 行の分割',
              TObject( xlDialogSplit ));
     AddObject( 'フォントの設定',
              TObject( xlDialogStandardFont ));
     AddObject( '標準の幅',
              TObject( xlDialogStandardWidth ));
     AddObject( 'フォントの設定',
              TObject( xlDialogStyle ));
     AddObject( '引用',
              TObject( xlDialogSubscribeTo ));
     AddObject( '集計の設定',
              TObject( xlDialogSubtotalCreate ));
     AddObject( 'プロパティ (ファイルの概要)',
              TObject( xlDialogSummaryInfo ));
     AddObject( 'テーブル',
              TObject( xlDialogTable ));
     AddObject( 'タブ オーダーの設定',
              TObject( xlDialogTabOrder ));
     AddObject( '区切り位置',
              TObject( xlDialogTextToColumns ));
     AddObject( 'ウィンドウの再表示',
              TObject( xlDialogUnhide ));
     AddObject( 'リンクの更新',
              TObject( xlDialogUpdateLink ));
     AddObject( 'VBA 挿入ファイル',
              TObject( xlDialogVbaInsertFile ));
     AddObject( 'VBA 作成アドイン',
              TObject( xlDialogVbaMakeAddin ));
     AddObject( 'VBA 手順定義',
              TObject( xlDialogVbaProcedureDefinition ));
     AddObject( '3D 表示',
              TObject( xlDialogView3d ));
     AddObject( 'Web オプション (エンコード)',
              TObject( xlDialogWebOptionsEncoding ));
     AddObject( 'Web オプション (ファイル)',
              TObject( xlDialogWebOptionsFiles ));
     AddObject( 'Web オプション (フォント)',
              TObject( xlDialogWebOptionsFonts ));
     AddObject( 'Web オプション (全般)',
              TObject( xlDialogWebOptionsGeneral ));
     AddObject( 'Web オプション (図)',
              TObject( xlDialogWebOptionsPictures ));
     AddObject( 'ウィンドウの移動',
              TObject( xlDialogWindowMove ));
     AddObject( 'ウィンドウ サイズ',
              TObject( xlDialogWindowSize ));
     AddObject( 'シートの移動またはコピー',
              TObject( xlDialogWorkbookAdd ));
     AddObject( 'シートの移動またはコピー',
              TObject( xlDialogWorkbookCopy ));
     AddObject( '挿入 (標準)',
              TObject( xlDialogWorkbookInsert ));
     AddObject( 'シートの移動またはコピー',
              TObject( xlDialogWorkbookMove ));
     AddObject( 'シート名の変更',
              TObject( xlDialogWorkbookName ));
     AddObject( '挿入 (標準)',
              TObject( xlDialogWorkbookNew ));
     AddObject( 'シート名の変更',
              TObject( xlDialogWorkbookOptions ));
     AddObject( 'ブックの保護',
              TObject( xlDialogWorkbookProtect ));
     AddObject( 'ブックのタブ分割',
              TObject( xlDialogWorkbookTabSplit ));
     AddObject( '再表示',
              TObject( xlDialogWorkbookUnhide ));
     AddObject( 'グループ編集',
              TObject( xlDialogWorkgroup ));
     AddObject( '作業状態設定',
              TObject( xlDialogWorkspace ));
     AddObject( 'ズーム',
              TObject( xlDialogZoom ));
     EndUpdate;
  end;
  ListBox1.Sorted := True;

    //フォーム表示開始時に開くブック名
  xlfBookFullPath := 'テスト.xls';
  //表示時に選択するセル
  xlfActiveCell := 'A2';
  //行列番号を表示する
  xlfDisplayHeadings := True;
  //枠線を表示する
  xlfDisplayGridLines := True;

  //元のOnShowを実行
  inherited;
end;

//=============================================================================
//  組み込みダイアログを表示
//  DialogオブジェクトをOleVariantで扱う場合
//=============================================================================
procedure TplExcelFormEx1.Button1Click(Sender: TObject);
var
  pIndex : OleVariant;
  AItem  : OleVariant;
begin
  //これがないと正常に表示されないダイアログがある
  xlfSetFocusExcel;
  pIndex := Integer(ListBox1.Items.Objects[ListBox1.ItemIndex]);
  try
    //ダイアログIDの値をEdit1に表示
    Edit1.Text := IntToStr(pIndex);
    AItem      := xlfExcelApp.Dialogs.Item[pIndex];
    AItem.Show;
  except
    raise;
  end;
  //これがないと正常に表示されないダイアログがある
  xlfSetFocusExcel;
end;




オブジェクトを OleVariant で使用する場合とその引数指定


TExcelApplication を使用したメソッド,プロパティでは引数を省略できません.ダイアログの表示ぐらいであれば,Show のスペルを間違うことはないと思いますから,上のコードのように,オブジェクトを OleVariant で扱えばコードは短くなります.

Show メソッドは,必要であれば次のように引数を指定できます.
Show メソッドの様に,汎用的なものは Arg1, Arg2 ,..., Arg10,.. となっていますが,他の個別のメソッド類の引数名は,VBA のヘルプに記載されている名前とほとんど同じとなっているようです.

下図は,VBA のヘルプで xlDialogFontProperties を検索した結果です.このヘルプの文章で引数の順番とその意味を確認することができます.3 番目の引数は size となっています.この size はフォントのサイズです.
これらの引数が実際に何をを意味するかは,実際に引数に値を与えて実行して確認することになります.MSDN にも VBA のヘルプにも,これ以上の詳しい説明はありません.



図3
引数の意味

下図は,実際にフォントのサイズを指定してダイアログを表示した結果です.
引数名を省略した場合は 1 番目の引数の値となります.下のコードでは font (フォント名) がそれら該当します.


図4
実行結果
  • フォント名とサイズを指定してダイアログを表示

リスト2
procedure TplExcelFormEx1.Button2Click(Sender: TObject);
var
  pIndex : OleVariant;
  AItem  : OleVariant;
begin
  pIndex := xlDialogFontProperties;
  try
    AItem           := xlfExcelApp.Dialogs.Item[pIndex];
    AItem.Show(Arg1 := 'MS 明朝', Arg3 := 20);
  except
    raise;
  end;
end;




コマンド ID によるダイアログの表示


コマンド ID にもダイアログを表示するものがあります.たとえば,次のコードはバージョン情報ダイアログを表示します.


図5
実行結果

リスト3
procedure TplExcelFormEx1.Button3Click(Sender: TObject);
var
  objCmdBars : OleVariant;
begin
  xlfSetFocusExcel;
  objCmdBars := xlfExcelApp.CommandBars;
  try
    objCmdBars.FindControl(ID := 927).Execute;
  except
  end;
end;