使用VBA显示/打开Excel内置对话框。

huangapple go评论90阅读模式
英文:

Using VBA for Showing/Opening Excel built-in dialog

问题

当使用

Application.Dialogs(xlDialogRun).Show

它显示宏对话框(xlDialogRun)吗?

Application.Dialogs(xlDialogMacroOptions).Show

不起作用。对话框类的Show方法失败。

同样,我需要打开/显示排序对话框

Application.Dialogs(xlDialogSort).Show

不起作用。对话框类的Show方法失败。

ActiveSheet.ListObjects(1).Sort.SortDialog

不起作用。对象不支持此属性或方法。

Excel 2021,VBA 7.1,Windows 11,64位

XlBuiltInDialog enumeration (Excel)

已安装Microsoft Office 16.0对象库。

从VBE菜单中选择View>Object Browser
然后将Libraries设置为Excel
搜索XlBuiltInDialog以显示“XlBuiltInDialog”的成员。

显示所有对话框

英文:

When Using

Application.Dialogs(xlDialogRun).Show

It shows the Macro Dialog (xlDialogRun) ?

Application.Dialogs(xlDialogMacroOptions).Show

Is not working. Show method of Dialog class failed

Same, I need to open/show the Sort Dialog

Application.Dialogs(xlDialogSort).Show

Is not working. Show method of Dialog class failed.

ActiveSheet.ListObjects(1).Sort.SortDialog

Is not working. Object does not support this property or method.

Excel 2021, VBA 7.1, Windows 11, 64 Bit

XlBuiltInDialog enumeration (Excel)

Microsoft Office 16.0 Object Library Installed.

From the VBE menu, select View > Object Browser
Then Set Libraries to Excel
Search for XlBuiltInDialog to display the Members of "XlBuiltInDialog"

Show all the Dialogs

答案1

得分: 1

People have mentioned needing to name the macro you're trying to get the options dialog for like so Application.Dialogs(xlDialogMacroOptions).Show ("yourMacro") and for the sort dialog, see here.

Some .Show require arguments or a previous action. Try to play around and for the arguments: see this github

Also see these examples on how to use the arguments to already change certain checkboxes in a dialogbox

英文:

People have mentioned needing to name the macro you're trying to get the options dialog for like so Application.Dialogs(xlDialogMacroOptions).Show ("yourMacro") and for the sort dialog, see here.

Some .Show require arguments or a previous action. Try to play around and for the arguments: see this github

Also see these examples on how to use the arguments to already change certain checkboxes in a dialogbox

答案2

得分: 0

以下是已翻译的代码部分:

Dim wb As Workbook
Dim ws As Worksheet
Dim tbl As ListObject
Dim rng As Range
Dim ac As Range

Set wb = ThisWorkbook
Set ws = wb.ActiveSheet
Set tbl = ws.ListObjects(1)
Set rng = tbl.Range
Set ac = ActiveCell

rng.Select
Application.Dialogs(xlDialogSort).Show
ac.Select
英文:

What works is

    Dim wb As Workbook
Dim ws As Worksheet
Dim tbl As ListObject
Dim rng As Range
Dim ac As Range

Set wb = ThisWorkbook
Set ws = wb.ActiveSheet
Set tbl = ws.ListObjects(1)
Set rng = tbl.Range
Set ac = ActiveCell

    rng.Select
    Application.Dialogs(xlDialogSort).Show
    ac.Select

huangapple
  • 本文由 发表于 2023年5月10日 19:13:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76217712.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定