"Unexpected Error" (Can I fix it, or possibly have VBA "x" out of it?)

0

I have some VBA code that refreshes//saves//closes my Excel reports in the morning.

Unfortunately, some of the reports are throwing an "unexpected error" which interrupts the script.

enter image description here

If I simply "x" out of the Unexpected Error message, the script continues to run smoothly.

MY QUESTION:

1) How can I fix the error? (I copied the details below)

2) If I can't fix the error, is there a way to have VBA "x" out of the message for me? (VBS script code at very bottom)

Thank you for any help you can provide. I'm fairly new to VBA but am really falling in love with it.

Feedback Type: Frown (Error)

Error Message:

Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND))

Stack Trace:

at Microsoft.Mashup.Client.Excel.Interop.NativeExcelInteropUtils.ValidateResult(Int32 result, Int32[] expectedValues) at Microsoft.Mashup.Client.Excel.Win32.NativeWinFormsTaskPaneFunctions.IsTaskPaneVisible(NativeTaskPaneType type, IntPtr uiFrame) at Microsoft.Mashup.Client.Excel.TaskPaneControls.QueriesAndConnectionsTaskPaneControl.EnsureWorkbookConnections() at Microsoft.Mashup.Client.Excel.TaskPaneControls.QueriesAndConnectionsTaskPaneControl.TryInitializeInternal() at Microsoft.Mashup.Client.Excel.TaskPaneControls.TaskPaneControl.TryInitialize(ITaskPane officeTaskPane) at Microsoft.Mashup.Client.Excel.CustomTaskPaneManager.TryCreateTaskPane(IWindowContext windowContext, ITaskPane& taskPane) at Microsoft.Mashup.Client.Excel.CustomTaskPaneManager.TryGetOrCreateTaskPane(IWindowContext windowContext, ITaskPane& taskPane) at Microsoft.Mashup.Client.Excel.CustomTaskPaneManagers.UpdateQueriesTaskPaneVisibility(IWindowContext windowContext) at Microsoft.Mashup.Client.Excel.ExcelEventHandler.PerformPeriodicUpdate(IEnumerable`1 queriesTaskPaneVisibilityUpdateWindows) at Microsoft.Mashup.Client.Excel.NativeEventHandler.b__11_0()
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)

Stack Trace Message: Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND))

Invocation Stack Trace: at

Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace() at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo..ctor(String message, Exception exception, Nullable`1 stackTraceInfo, String messageDetail) at Microsoft.Mashup.Client.Excel.Native.NativeUserFeedbackServices.ReportException(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, Boolean useGDICapture) at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.<>c__DisplayClass14_0.b__0() at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.HandleException(Exception e) at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action) at Microsoft.Mashup.Client.Excel.ExcelCallbackManager.InvokeAndReturnHResult(Action action)

InnerException.Stack Trace Message:

Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND))

InnerException.Stack Trace:

InnerException.Invocation Stack Trace: at Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace() at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo.GetFeedbackValuesFromException(Exception e, String prefix) at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo.CreateAdditionalErrorInfo(Exception e) at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo..ctor(String message, Exception exception, Nullable`1 stackTraceInfo, String messageDetail) at Microsoft.Mashup.Client.Excel.Native.NativeUserFeedbackServices.ReportException(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, Boolean useGDICapture) at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.<>c__DisplayClass14_0.b__0() at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.HandleException(Exception e) at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action) at Microsoft.Mashup.Client.Excel.ExcelCallbackManager.InvokeAndReturnHResult(Action action)

Supports Premium Content: True


VBA CODE:

Dim objExcel
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open("S:\Analyst_Reporting\Automation\PIECES AUTOMATION BOOK.xlsm") 'THIS OPENS THE MASTER EXCEL BOOK 
objExcel.Visible = True

objExcel.Run "ThisWorkbook.APDPIECES"  'THIS OPENS THE FIRST REPORT
set wbk = objExcel.ActiveWorkbook
objExcel.Run "ThisWorkbook.helloworld" 'THIS REFRESHES THE REPORT
wbk.save
wbk.close(0)

objExcel.Run"THISWORKBOOK.APDTIMESTAMP"   'TIMESTAMP IN THE MASTER BOOK 
objExcel.Run "Thisworkbook.SAVEBOOK"      
objExcel.Run"ThisWorkbook.PIPPIECES"
set wbk = objExcel.ActiveWorkbook
objExcel.Run "ThisWorkbook.helloworld"
wbk.save
wbk.close(0)

objExcel.Run"ThisWorkbook.PIPTIMESTAMP"
objExcel.Run "Thisworkbook.SAVEBOOK"
excel
vba
automation
asked on Stack Overflow Jan 2, 2020 by BruceBalistreri1 • edited Jan 2, 2020 by braX

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0