想用VBA列出内置函数

我想以编程方式使用VBA,生成Access文件中可用的VBA函数的列表(文本,表,无关紧要)。 我不想生成用户编写的函数列表。 。 。 我正在寻找生成内置函数的列表。 我会寻找生成一个列表,如下所示:

left,instr,date,mid,asc,reverse,month,cstr等等等等

我在VBA对象浏览器中看到,转换,date时间,文件系统,金融,信息,交互,math和string的类名下有VBA命令的全部集合。

我尝试过所有在VBA中尝试枚举这些类的对象声明,但都没有成功。 我希望能够做的就是枚举函数名称。

当前版本的Rubberduck (2.0.12,尚未发布 – 计划在二月初) 将使 COM API再次运行(2.0.11破坏它),所以如果你可以构build当前版本(“下一个”分支,使用Visual Studio )…或者等待2.0.12,你可以参考Rubberduck的types库,并写下如下的VBA代码:

 Option Explicit Public Sub ListAllLoadedDeclarations() Dim ducky As Rubberduck.ParserState Set ducky = New Rubberduck.ParserState ducky.Initialize Application.VBE ducky.Parse Dim item As Variant Dim typedItem As Rubberduck.Declaration For Each item In ducky.AllDeclarations Set typedItem = item If typedItem.DeclarationType = DeclarationType_Function _ Or typedItem.DeclarationType = DeclarationType_Procedure _ Or typedItem.DeclarationType = DeclarationType_PropertyGet _ Or typedItem.DeclarationType = DeclarationType_PropertyLet _ Or typedItem.DeclarationType = DeclarationType_PropertySet _ Then ' Project.Module.Member Debug.Print typedItem.ParentDeclaration.ParentDeclaration.Name & "." & _ typedItem.ParentDeclaration.Name & "." & _ typedItem.Name & " (" & DeclarationTypeName(typedItem.DeclarationType) & ")" End If Next End Sub Private Function DeclarationTypeName(ByVal value As Rubberduck.DeclarationType) As String Select Case value Case DeclarationType_Function DeclarationTypeName = "Function" Case DeclarationType_Procedure DeclarationTypeName = "Sub" Case DeclarationType_PropertyGet DeclarationTypeName = "Property Get" Case DeclarationType_PropertyLet DeclarationTypeName = "Property Let" Case DeclarationType_PropertySet DeclarationTypeName = "Property Set" End Select End Function 

这将列出所有早期绑定引用(包括VBE中的所有“用户代码”)中的所有SubFunctionProperty成员,将它们打印到即时窗格 (您将要更改Debug.Print以写入文件,也许),看起来像这样(在Excel项目中):

 (snip) Excel.PivotTable.Name (Property Let) Excel.PivotTable.ViewCalculatedMembers (Property Get) Excel.PivotTable.SourceData (Property Get) Excel.PivotTable.InGridDropZones (Property Get) Excel.PivotTable.GrandTotalName (Property Get) Excel.PivotTable.Update (Sub) Excel.PivotTable.SmallGrid (Property Get) Excel.PivotTable.EnableWriteback (Property Get) Excel.PivotTable.Version (Property Get) Excel.PivotTable.ShowCellBackgroundFromOLAP (Property Get) Excel.PivotTable.RowRange (Property Get) Excel.PivotTable.CalculatedFields (Function) Excel.PivotTable.AllocateChanges (Sub) Excel.PivotTable.AllocationValue (Property Get) Excel.PivotTable.DisplayMemberPropertyTooltips (Property Let) Excel.PivotTable.CacheIndex (Property Let) Excel.PivotTable.CompactRowIndent (Property Get) Excel.PivotTable.DiscardChanges (Sub) Excel.PivotTable.EnableDrilldown (Property Get) Excel.PivotTable.AlternativeText (Property Get) Excel.PivotTable.DataLabelRange (Property Get) Excel.PivotTable.ListFormulas (Sub) Excel.PivotTable.AllowMultipleFilters (Property Let) Excel.PivotTable.RowAxisLayout (Sub) Excel.PivotTable.ShowTableStyleColumnHeaders (Property Get) Excel.PivotTable.Tag (Property Get) Excel.PivotTable.LayoutRowDefault (Property Get) Excel.PivotTable.DataPivotField (Property Get) Excel.PivotTable.TableStyle (Property Get) Excel.PivotTable.DisplayNullString (Property Get) Excel.PivotTable.PageRange (Property Get) Excel.PivotTable.CalculatedMembersInFilters (Property Get) Excel.PivotTable.ShowPageMultipleItemLabel (Property Get) Excel.PivotTable.Summary (Property Let) Excel.PivotTable.DisplayFieldCaptions (Property Let) Excel.PivotTable.ChangePivotCache (Sub) Excel.PivotTable.ShowTableStyleRowStripes (Property Let) Excel.PivotTable.EnableWizard (Property Let) Excel.PivotTable.PageFields (Property Get) Excel.PivotTable.PageFieldOrder (Property Get) Excel.PivotTable.PrintTitles (Property Let) Excel.PivotTable.SubtotalHiddenPageItems (Property Get) Excel.PivotTable.VisualTotalsForSets (Property Let) Excel.PivotTable.ShowTableStyleRowHeaders (Property Let) Excel.PivotTable.PivotSelectionStandard (Property Get) Excel.PivotTable.AddFields (Function) Excel.PivotTable.CompactLayoutRowHeader (Property Get) Excel.PivotTable.RepeatItemsOnEachPrintedPage (Property Get) Excel.PivotTable.AllocationMethod (Property Let) Excel.PivotTable.VacatedStyle (Property Get) Excel.PivotTable.Value (Property Get) Excel.PivotTable.GetPivotData (Function) Excel.PivotTable.InnerDetail (Property Let) Excel.PivotTable.Format (Sub) Excel.PivotTable.PageFieldStyle (Property Get) Excel.PivotTable.SubtotalLocation (Sub) Excel.PivotTable.ShowPages (Function) Excel.PivotTable.ShowValuesRow (Property Let) Excel.PivotTable.MDX (Property Get) Excel.PivotTable.DataBodyRange (Property Get) Excel.PivotTable.PreserveFormatting (Property Get) Excel.PivotTable.DisplayContextTooltips (Property Let) Excel.PivotTable.ChangeList (Property Get) Excel.PivotTable.Location (Property Let) Excel.PivotTable.PivotSelection (Property Let) Excel.PivotTable.RefreshDate (Property Get) Excel.PivotTable.VisibleFields (Property Get) Excel.PivotTable.MergeLabels (Property Get) Excel.PivotTable.EnableDataValueEditing (Property Let) Excel.PivotTable.TableRange1 (Property Get) Excel.PivotTable.ShowDrillIndicators (Property Get) Excel.PivotTable.Allocation (Property Get) Excel.PivotTable.Parent (Property Get) Excel.PivotTable.DisplayImmediateItems (Property Let) Excel.PivotTable.HasAutoFormat (Property Get) Excel.PivotTable.PageFieldWrapCount (Property Get) Excel.PivotTable.EnableFieldDialog (Property Let) Excel.PivotTable.RepeatAllLabels (Sub) Excel.PivotTable.VisualTotals (Property Get) Excel.PivotTable.DisplayEmptyColumn (Property Get) Excel.PivotTable.CubeFields (Property Get) Excel.PivotTable.ShowTableStyleLastColumn (Property Get) Excel.PivotTable.PivotTableWizard (Sub) Excel.PivotTable.PageRangeCells (Property Get) Excel.PivotTable.DisplayErrorString (Property Let) Excel.PivotTable.RowGrand (Property Let) Excel.PivotTable.SortUsingCustomLists (Property Get) Excel.PivotTable._Default (Property Let) Excel.PivotTable.ColumnGrand (Property Let) Excel.PivotTable.CalculatedMembers (Property Get) Excel.PivotTable.Application (Property Get) Excel.PivotTable.ShowTableStyleColumnStripes (Property Get) Excel.PivotTable.PivotColumnAxis (Property Get) Excel.PivotTable.NullString (Property Get) Excel.PivotTable.Slicers (Property Get) Excel.PivotTable.ErrorString (Property Let) Excel.PivotTable.AllocationWeightExpression (Property Get) Excel.PivotTable.DisplayEmptyRow (Property Get) Excel.PivotTable.SaveData (Property Get) Excel.PivotTable.EnableFieldList (Property Get) Excel.PivotTable.SelectionMode (Property Let) Excel.PivotTable.FieldListSortAscending (Property Get) Excel.PivotTable.RefreshDataSourceValues (Sub) Excel.PivotTable.ViewCalculatedMembers (Property Let) Excel.PivotTable.SourceData (Property Let) Excel.PivotTable.TableStyle2 (Property Get) Excel.PivotTable.CommitChanges (Sub) Excel.PivotTable.InGridDropZones (Property Let) Excel.PivotTable.GrandTotalName (Property Let) Excel.PivotTable.TotalsAnnotation (Property Get) Excel.PivotTable.CompactLayoutColumnHeader (Property Get) Excel.PivotTable.PrintDrillIndicators (Property Get) Excel.PivotTable.SmallGrid (Property Let) Excel.PivotTable.EnableWriteback (Property Let) Excel.PivotTable.ManualUpdate (Property Get) Excel.PivotTable.Name (Property Get) Excel.PivotTable.ShowCellBackgroundFromOLAP (Property Let) Excel.IFont.TintAndShade (Property Let) Excel.IFont.Creator (Property Get) Excel.IFont.ThemeColor (Property Get) Excel.IFont.Size (Property Get) Excel.IFont.Italic (Property Get) Excel.IFont.Strikethrough (Property Get) Excel.IFont.FontStyle (Property Get) Excel.IFont.Parent (Property Get) Excel.IFont.Color (Property Get) Excel.IFont.Name (Property Get) Excel.IFont.OutlineFont (Property Get) Excel.IFont.Application (Property Get) Excel.IFont.Underline (Property Get) Excel.IFont.ThemeColor (Property Let) Excel.IFont.Size (Property Let) Excel.IFont.Italic (Property Let) Excel.IFont.Strikethrough (Property Let) Excel.IFont.FontStyle (Property Let) Excel.IFont.ThemeFont (Property Get) Excel.IFont.Color (Property Let) Excel.IFont.Name (Property Let) Excel.IFont.OutlineFont (Property Let) Excel.IFont.Underline (Property Let) Excel.IFont.Shadow (Property Get) Excel.IFont.ThemeFont (Property Let) Excel.IFont.Superscript (Property Get) Excel.IFont.Subscript (Property Get) Excel.IFont.ColorIndex (Property Get) Excel.IFont.Shadow (Property Let) Excel.IFont.Superscript (Property Let) Excel.IFont.Subscript (Property Let) Excel.IFont.Bold (Property Get) Excel.IFont.ColorIndex (Property Let) Excel.IFont.Background (Property Get) Excel.IFont.Bold (Property Let) Excel.IFont.TintAndShade (Property Get) Excel.IFont.Background (Property Let) Rubberduck._Extension.OnBeginShutdown (Sub) Rubberduck._Extension.OnConnection (Sub) Rubberduck._Extension.OnStartupComplete (Sub) Rubberduck._Extension.ToString (Property Get) Rubberduck._Extension.OnAddInsUpdate (Sub) Rubberduck._Extension.GetHashCode (Function) Rubberduck._Extension.OnDisconnection (Sub) Rubberduck._Extension.GetType (Function) Rubberduck._Extension.Equals (Function) Excel.IPivotLines.Application (Property Get) Excel.IPivotLines.Parent (Property Get) Excel.IPivotLines.Creator (Property Get) Excel.IPivotLines.Item (Property Get) Excel.IPivotLines.Count (Property Get) Excel.IPivotLines._NewEnum (Property Get) Excel.IPivotLines._Default (Property Get) Office.ICTPFactory.CreateCTP (Function) Office.IRibbonControl.Tag (Property Get) Office.IRibbonControl.Context (Property Get) Office.IRibbonControl.Id (Property Get) Office.FoundFiles.Application (Property Get) Office.FoundFiles.Count (Property Get) Office.FoundFiles.Creator (Property Get) Office.FoundFiles._NewEnum (Property Get) Office.FoundFiles.Item (Property Get) Office.PickerDialog.Creator (Property Get) Office.PickerDialog.CreatePickerResults (Function) Office.PickerDialog.Resolve (Function) Office.PickerDialog.Title (Property Let) Office.PickerDialog.Show (Function) Office.PickerDialog.Title (Property Get) Office.PickerDialog.DataHandlerId (Property Let) Office.PickerDialog.Properties (Property Get) Office.PickerDialog.Application (Property Get) Office.PickerDialog.DataHandlerId (Property Get) Excel.Menu.Enabled (Property Let) Excel.Menu.MenuItems (Property Get) Excel.Menu.Enabled (Property Get) Excel.Menu.Delete (Sub) Excel.Menu.Parent (Property Get) Excel.Menu.Caption (Property Let) Excel.Menu.Index (Property Get) Excel.Menu.Caption (Property Get) Excel.Menu.Creator (Property Get) Excel.Menu.Application (Property Get) 

请注意,这包括隐藏的成员,而且Rubberduck也知道返回types,参数和可见性,但是API当前使得有效地查询事情变得有点困难。

Rubberduck的COM API仍然是一个实验性的function,受到重大变化和非常开放的build议和function请求,所以我不会build议在任何生产代码中使用它 – 但玩它肯定可以让你比刮MSDN更快或编写自己的COMtypes库读取器/reflection器。


由于我们将这些信息序列化为XML,因此我们的testing和网站的“试用代码检查”function可以在VBE之外工作,您也可以尝试反序列化我们的XML文件 ,并获取所有这些信息。


充分披露:我深入参与了Rubberduck的开发。

您可以从此页面左侧的列表中检索列表。