@@ -28,8 +28,18 @@ public void SetProjectConditionalCompilationArgsRaw(string projectName, string n
28
28
=> VBETypeLibsAPI . SetProjectConditionalCompilationArgsRaw ( _ide , projectName , newConditionalArgs ) ;
29
29
public bool DoesClassImplementInterface ( string projectName , string className , string interfaceProgId )
30
30
=> VBETypeLibsAPI . DoesClassImplementInterface ( _ide , projectName , className , interfaceProgId ) ;
31
- public string GetUserFormControlType ( string projectName , string userFormName , string controlName )
31
+ public string GetUserFormControlType ( string projectName , string userFormName , string controlName )
32
32
=> VBETypeLibsAPI . GetUserFormControlType ( _ide , projectName , userFormName , controlName ) ;
33
+ public string GetDocumentClassControlType ( string projectName , string documentClassName , string controlName )
34
+ => VBETypeLibsAPI . GetDocumentClassControlType ( _ide , projectName , documentClassName , controlName ) ;
35
+ public bool IsExcelWorksheet ( string projectName , string className )
36
+ => VBETypeLibsAPI . IsExcelWorksheet ( _ide , projectName , className ) ;
37
+ public bool IsExcelWorkbook ( string projectName , string className )
38
+ => VBETypeLibsAPI . IsExcelWorkbook ( _ide , projectName , className ) ;
39
+ public bool IsAccessForm ( string projectName , string className )
40
+ => VBETypeLibsAPI . IsAccessForm ( _ide , projectName , className ) ;
41
+ public bool IsAccessReport ( string projectName , string className )
42
+ => VBETypeLibsAPI . IsAccessReport ( _ide , projectName , className ) ;
33
43
public string DocumentAll ( )
34
44
=> VBETypeLibsAPI . DocumentAll ( _ide ) ;
35
45
}
@@ -480,6 +490,112 @@ public static bool IsExcelWorksheet(TypeLibWrapper projectTypeLib, string classN
480
490
return DoesClassImplementInterface ( projectTypeLib , className , "Excel._Worksheet" ) ;
481
491
}
482
492
493
+ /// <summary>
494
+ /// Determines whether the specified document class is an Excel Workbook
495
+ /// </summary>
496
+ /// <param name="ide">Safe-com wrapper representing the VBE</param>
497
+ /// <param name="projectName">VBA Project name, as declared in the VBE</param>
498
+ /// <param name="className">Document class name, as declared in the VBA project</param>
499
+ /// <returns>bool indicating whether the class is an Access Form</returns>
500
+ public static bool IsAccessForm ( IVBE ide , string projectName , string className )
501
+ {
502
+ using ( var typeLibs = new VBETypeLibsAccessor ( ide ) )
503
+ {
504
+ return IsAccessForm ( typeLibs . Get ( projectName ) , className ) ;
505
+ }
506
+ }
507
+
508
+ /// <summary>
509
+ /// Determines whether the specified document class is an Excel Workbook
510
+ /// </summary>
511
+ /// <param name="project">Safe-com wrapper representing the VBA project</param>
512
+ /// <param name="className">Document class name, as declared in the VBA project</param>
513
+ /// <returns>bool indicating whether the class is an Access Form</returns>
514
+ public static bool IsAccessForm ( IVBProject project , string className )
515
+ {
516
+ using ( var typeLib = TypeLibWrapper . FromVBProject ( project ) )
517
+ {
518
+ return IsAccessForm ( typeLib , className ) ;
519
+ }
520
+ }
521
+
522
+ /// <summary>
523
+ /// Determines whether the specified document class is an Excel Workbook
524
+ /// </summary>
525
+ /// <param name="project">Safe-com wrapper representing the VBA component</param>
526
+ /// <returns>bool indicating whether the class is an Access Form</returns>
527
+ public static bool IsAccessForm ( IVBComponent component )
528
+ {
529
+ return IsAccessForm ( component . ParentProject , component . Name ) ;
530
+ }
531
+
532
+ /// <summary>
533
+ /// Determines whether the specified document class is an Excel Workbook
534
+ /// </summary>
535
+ /// <param name="projectTypeLib">Low-level ITypeLib wrapper representing the VBA project</param>
536
+ /// <param name="className">Document class name, as declared in the VBA project</param>
537
+ /// <returns>bool indicating whether the class is an Access Form</returns>
538
+ public static bool IsAccessForm ( TypeLibWrapper projectTypeLib , string className )
539
+ {
540
+ // The interface used by an Access form depends on the version of Access hosting the form
541
+ // so we have to check for the current known interface prog-ids
542
+ return DoesClassImplementInterface ( projectTypeLib , className ,
543
+ new string [ ] { "Access._Form" , "Access._Form2" , "Access._Form3" } , out int matchIndex ) ;
544
+ }
545
+
546
+ /// <summary>
547
+ /// Determines whether the specified document class is an Excel Workbook
548
+ /// </summary>
549
+ /// <param name="ide">Safe-com wrapper representing the VBE</param>
550
+ /// <param name="projectName">VBA Project name, as declared in the VBE</param>
551
+ /// <param name="className">Document class name, as declared in the VBA project</param>
552
+ /// <returns>bool indicating whether the class is an Access Form</returns>
553
+ public static bool IsAccessReport ( IVBE ide , string projectName , string className )
554
+ {
555
+ using ( var typeLibs = new VBETypeLibsAccessor ( ide ) )
556
+ {
557
+ return IsAccessReport ( typeLibs . Get ( projectName ) , className ) ;
558
+ }
559
+ }
560
+
561
+ /// <summary>
562
+ /// Determines whether the specified document class is an Excel Workbook
563
+ /// </summary>
564
+ /// <param name="project">Safe-com wrapper representing the VBA project</param>
565
+ /// <param name="className">Document class name, as declared in the VBA project</param>
566
+ /// <returns>bool indicating whether the class is an Access Form</returns>
567
+ public static bool IsAccessReport ( IVBProject project , string className )
568
+ {
569
+ using ( var typeLib = TypeLibWrapper . FromVBProject ( project ) )
570
+ {
571
+ return IsAccessReport ( typeLib , className ) ;
572
+ }
573
+ }
574
+
575
+ /// <summary>
576
+ /// Determines whether the specified document class is an Excel Workbook
577
+ /// </summary>
578
+ /// <param name="project">Safe-com wrapper representing the VBA component</param>
579
+ /// <returns>bool indicating whether the class is an Access Form</returns>
580
+ public static bool IsAccessReport ( IVBComponent component )
581
+ {
582
+ return IsAccessReport ( component . ParentProject , component . Name ) ;
583
+ }
584
+
585
+ /// <summary>
586
+ /// Determines whether the specified document class is an Excel Workbook
587
+ /// </summary>
588
+ /// <param name="projectTypeLib">Low-level ITypeLib wrapper representing the VBA project</param>
589
+ /// <param name="className">Document class name, as declared in the VBA project</param>
590
+ /// <returns>bool indicating whether the class is an Access Form</returns>
591
+ public static bool IsAccessReport ( TypeLibWrapper projectTypeLib , string className )
592
+ {
593
+ // The interface used by an Access form depends on the version of Access hosting the form
594
+ // so we have to check for the current known interface prog-ids
595
+ return DoesClassImplementInterface ( projectTypeLib , className ,
596
+ new string [ ] { "Access._Report" , "Access._Report2" , "Access._Report3" } , out int matchIndex ) ;
597
+ }
598
+
483
599
/// <summary>
484
600
/// Determines whether the specified VBA class implements a specific interface
485
601
/// </summary>
@@ -814,7 +930,72 @@ public static string GetUserFormControlType(TypeInfoWrapper userFormTypeInfo, st
814
930
{
815
931
return userFormTypeInfo . ImplementedInterfaces . Get ( "FormItf" ) . GetControlType ( controlName ) . GetProgID ( ) ;
816
932
}
933
+
934
+ /// <summary>
935
+ /// Returns the class progID of a control on a UserForm
936
+ /// </summary>
937
+ /// <param name="ide">Safe-com wrapper representing the VBE</param>
938
+ /// <param name="projectName">VBA Project name, as declared in the VBE</param>
939
+ /// <param name="documentClassName">Document class name, as declared in the VBA project</param>
940
+ /// <param name="controlName">Control name, as declared on the UserForm</param>
941
+ /// <returns>string class progID of the specified control on a UserForm, e.g. "MSForms.CommandButton"</returns>
942
+ public static string GetDocumentClassControlType ( IVBE ide , string projectName , string documentClassName , string controlName )
943
+ {
944
+ using ( var typeLibs = new VBETypeLibsAccessor ( ide ) )
945
+ {
946
+ return GetDocumentClassControlType ( typeLibs . Get ( projectName ) , documentClassName , controlName ) ;
947
+ }
948
+ }
949
+
950
+ /// <summary>
951
+ /// Returns the class progID of a control on a UserForm
952
+ /// </summary>
953
+ /// <param name="project">Safe-com wrapper representing the VBA project</param>
954
+ /// <param name="documentClassName">Document class name, as declared in the VBA project</param>
955
+ /// <param name="controlName">Control name, as declared on the UserForm</param>
956
+ /// <returns>string class progID of the specified control on a UserForm, e.g. "MSForms.CommandButton"</returns>
957
+ public static string GetDocumentClassControlType ( IVBProject project , string documentClassName , string controlName )
958
+ {
959
+ using ( var typeLib = TypeLibWrapper . FromVBProject ( project ) )
960
+ {
961
+ return GetDocumentClassControlType ( typeLib , documentClassName , controlName ) ;
962
+ }
963
+ }
964
+
965
+ /// <summary>
966
+ /// Returns the class progID of a control on a UserForm
967
+ /// </summary>
968
+ /// <param name="projectTypeLib">Low-level ITypeLib wrapper representing the VBA project</param>
969
+ /// <param name="documentClassName">Document class name, as declared in the VBA project</param>
970
+ /// <param name="controlName">Control name, as declared on the UserForm</param>
971
+ /// <returns>string class progID of the specified control on a UserForm, e.g. "MSForms.CommandButton"</returns>
972
+ public static string GetDocumentClassControlType ( TypeLibWrapper projectTypeLib , string documentClassName , string controlName )
973
+ {
974
+ return GetDocumentClassControlType ( projectTypeLib . TypeInfos . Get ( documentClassName ) , controlName ) ;
975
+ }
976
+
977
+ /// <summary>
978
+ /// Returns the class progID of a control on a UserForm
979
+ /// </summary>
980
+ /// <param name="ide">Safe-com wrapper representing the UserForm VBA component</param>
981
+ /// <param name="controlName">Control name, as declared on the UserForm</param>
982
+ /// <returns>string class progID of the specified control on a UserForm, e.g. "MSForms.CommandButton"</returns>
983
+ public static string GetDocumentClassControlType ( IVBComponent component , string controlName )
984
+ {
985
+ return GetDocumentClassControlType ( component . ParentProject , component . Name , controlName ) ;
986
+ }
817
987
988
+ /// <summary>
989
+ /// Returns the class progID of a control on a UserForm
990
+ /// </summary>
991
+ /// <param name="documentClass">Low-level ITypeLib wrapper representing the UserForm VBA component</param>
992
+ /// <param name="controlName">Control name, as declared on the UserForm</param>
993
+ /// <returns>string class progID of the specified control on a UserForm, e.g. "MSForms.CommandButton"</returns>
994
+ public static string GetDocumentClassControlType ( TypeInfoWrapper documentClass , string controlName )
995
+ {
996
+ return documentClass . GetSafeImplementedTypeInfo ( 0 ) . GetControlType ( controlName ) . GetProgID ( ) ;
997
+ }
998
+
818
999
/// <summary>
819
1000
/// Retreives the TYPEFLAGS of a VBA component (e.g. module/class), providing flags like TYPEFLAG_FCANCREATE, TYPEFLAG_FPREDECLID
820
1001
/// </summary>
@@ -944,6 +1125,7 @@ public static string DocumentAll(IVBE ide)
944
1125
{
945
1126
typeLib . Document ( output ) ;
946
1127
}
1128
+
947
1129
return output . ToString ( ) ;
948
1130
}
949
1131
}
0 commit comments