在将Office升级到Office 2013 Pro Plus后,尝试编译VB6 Outlook加载项组件时,我遇到了一个令人生气的问题。
错误
编译错误:Visual Basic中不支持自动化类型
正在抛弃:
Implements IDExtensibility2
我将在下面粘贴该文件中的完整代码。
在另一台PC上,我设法完成所有设置,并将Office升级到2012并且编译没有问题,但现在在同一台PC上 - 我得到了同样的错误。我在过渡期间对Office安装进行了大量的讨论,所以我无法准确地告诉你我在工作和不工作之间做了什么,但最重要的是它似乎不应该超出我做任何事情的可能性我正在努力(正如我已经做到的那样!),我只需要一些指导,了解我可能需要做些什么来恢复工作设置。任何想法??
Implements IDTExtensibility2
Private gBaseClass As New clsOlkAddIn
Private Sub IDTExtensibility2_OnAddInsUpdate(custom() As Variant)
'To Be Declared for IDTExtensibility2
End Sub
Private Sub IDTExtensibility2_OnBeginShutdown(custom() As Variant)
'To Be Declared for IDTExtensibility2
End Sub
Private Sub IDTExtensibility2_OnConnection(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
gBaseClass.InitHandler Application, AddInInst.ProgId
End Sub
Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode _
As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
Dim objCB As Office.CommandBar
On Error Resume Next
'If RemoveMode = ext_dm_UserClosed Then
Set objCB = golApp.ActiveExplorer.CommandBars("Addin")
objCB.FindControl(Type:=msoControlPopup, Tag:="Menu").Delete
objCB.FindControl(Type:=msoControlButton, Tag:="AddEmailsButton").Delete
objCB.FindControl(Type:=msoControlButton, Tag:="SyncContactsButton").Delete
objCB.FindControl(Type:=msoControlButton, Tag:="SyncTasksButton").Delete
objCB.FindControl(Type:=msoControlButton, Tag:="SyncCalendarButton").Delete
objCB.Delete
'End If
gBaseClass.UnInitHandler
Set gBaseClass = Nothing
End Sub
Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)
'To Be Declared for IDTExtensibility2
End Sub
答案 0 :(得分:1)
我今天发现这个错误的另一个原因是在函数上有一个可选参数并给它一个默认值,例如
Public Function Foo(MyString as String,Optional MyVariant as variant = null)
将此更改为:
Public Function Foo(MyString as String,可选MyVariant作为变体)
解决了它,我没有像上面那样简单地到达那里(因此,为什么我在这里闲逛),我确实将可选参数首先更改为字符串,实际上,即使是变量参数,默认值为Null以外的任何值。这是导致错误的默认值Null。
答案 1 :(得分:0)
正如您在答案中所确认的(在评论中),确保您已升级到最新的Service Pack始终是最佳选择,除非您知道您依赖于在以后的Service Pack中删除或更改的功能。
答案 2 :(得分:0)
安装“ Visual Basic 6.0 Service Pack 6运行时扩展文件的累积更新汇总”(https://support.microsoft.com/en-us/help/957924/description-of-the-cumulative-update-rollup-for-the-visual-basic-6-0-s)解决了我的实例中的此错误。