我有几个在计划任务上运行的excel 2013 / 32bit VBA宏。我每天都跑了几个月没有问题。
当我激活“电源查询”加载项并更改其他内容时,宏会挂起,并显示以下错误:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
Microsoft.Mashup.Client.ClientShared.Com.ComWrapperException: Cannot cast null to type 'System.Double'. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Mashup.Client.ClientShared.Com.ComWrapper.As[T](Object value)
--- End of inner exception stack trace ---
at Microsoft.Mashup.Client.ClientShared.Com.ComWrapper.As[T](Object value)
at Microsoft.Mashup.Client.Excel.Com.ExcelComWrapper.AsIntFromDouble(Object value)
at Microsoft.Mashup.Client.Excel.Com.Application.get_Build()
at Microsoft.Mashup.Client.Excel.Com.ApplicationFeatures..ctor(IApplication application)
at Microsoft.Mashup.Client.Excel.Com.Application..ctor(Object application, Boolean enableEvents)
at Microsoft.Mashup.Client.Excel.AddIn.TryCreateApplication(Object appObject, IApplication& application)
at Microsoft.Mashup.Client.Excel.AddIn.Extensibility.IDTExtensibility2.OnConnection(Object application, ext_ConnectMode connectMode, Object addInInst, Array& custom)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1590.0 built by: NETFXREL2
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
Microsoft.Mashup.Client.Excel
Assembly Version: 1.0.0.0
Win32 Version: 2.35.4399.761
CodeBase: file:///C:/Program%20Files%20(x86)/Microsoft%20Power%20Query%20for%20Excel/bin/Microsoft.Mashup.Client.Excel.dll
----------------------------------------
Extensibility
Assembly Version: 7.0.3300.0
Win32 Version: 7.00.9466
CodeBase: file:///C:/Windows/assembly/GAC/Extensibility/7.0.3300.0__b03f5f7f11d50a3a/Extensibility.dll
----------------------------------------
office
Assembly Version: 15.0.0.0
Win32 Version: 15.0.4859.1000
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/office/15.0.0.0__71e9bce111e9429c/office.dll
----------------------------------------
Microsoft.Mashup.Client.Windows
Assembly Version: 1.0.0.0
Win32 Version: 2.35.4399.761
CodeBase: file:///C:/Program%20Files%20(x86)/Microsoft%20Power%20Query%20for%20Excel/bin/Microsoft.Mashup.Client.Windows.DLL
----------------------------------------
Microsoft.Mashup.Document
Assembly Version: 1.0.0.0
Win32 Version: 2.35.4399.761
CodeBase: file:///C:/Program%20Files%20(x86)/Microsoft%20Power%20Query%20for%20Excel/bin/Microsoft.Mashup.Document.DLL
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1590.0 built by: NETFXREL2
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1590.0 built by: NETFXREL2
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1590.0 built by: NETFXREL2
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1590.0 built by: NETFXREL2
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
Microsoft.MashupEngine
Assembly Version: 1.0.0.0
Win32 Version: 2.35.4399.761
CodeBase: file:///C:/Program%20Files%20(x86)/Microsoft%20Power%20Query%20for%20Excel/bin/Microsoft.MashupEngine.DLL
----------------------------------------
Microsoft.Mashup.Client.AddinTelemetry
Assembly Version: 1.0.0.0
Win32 Version: 2.35.4399.761
CodeBase: file:///C:/Program%20Files%20(x86)/Microsoft%20Power%20Query%20for%20Excel/bin/Microsoft.Mashup.Client.AddinTelemetry.DLL
----------------------------------------
Microsoft.Mashup.ProviderShared
Assembly Version: 1.0.0.0
Win32 Version: 2.35.4399.761
CodeBase: file:///C:/Program%20Files%20(x86)/Microsoft%20Power%20Query%20for%20Excel/bin/Microsoft.Mashup.ProviderShared.DLL
----------------------------------------
Microsoft.Office.Interop.Excel
Assembly Version: 15.0.0.0
Win32 Version: 15.0.4569.1506
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.Office.Interop.Excel/15.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll
----------------------------------------
Microsoft.Mashup.Client.Models
Assembly Version: 1.0.0.0
Win32 Version: 2.35.4399.761
CodeBase: file:///C:/Program%20Files%20(x86)/Microsoft%20Power%20Query%20for%20Excel/bin/Microsoft.Mashup.Client.Models.DLL
----------------------------------------
Microsoft.Practices.Unity
Assembly Version: 2.1.505.0
Win32 Version: 2.1.505.2
CodeBase: file:///C:/Program%20Files%20(x86)/Microsoft%20Power%20Query%20for%20Excel/bin/Microsoft.Practices.Unity.DLL
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1590.0 built by: NETFXREL2
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1590.0 built by: NETFXREL2
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Microsoft.Mashup.EventSource
Assembly Version: 1.0.0.0
Win32 Version: 2.35.4399.761
CodeBase: file:///C:/Program%20Files%20(x86)/Microsoft%20Power%20Query%20for%20Excel/bin/Microsoft.Mashup.EventSource.DLL
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
当我删除加载项“power query”并运行宏时,不会发生错误。
我的问题是........
我可以将哪些代码添加到我的宏中,这样我可以让加载项处于活动状态,但不会导致宏挂起上面的错误消息?
谢谢,
BennyB
答案 0 :(得分:0)
您需要执行以下操作:
检查您是否有最新版本的PowerQuery。
打开VBA编辑器(Alt + F11)并在您的开头设置一个断点 宏。然后逐步执行它以找到导致PQ的行 挂。您也可以在此模式下启动宏,方法是将光标放入并按F8。
单击&#34;发送皱眉&#34;,向某些人报告错误 您的代码,包括导致挂起的行。
你也可以在这里写,因为我们可能可能会提出建议(因为这似乎是PowerQuery中未处理的异常)。