英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论