PDA

View Full Version : Sleeper: Supress All Excel Messages



bitpusher
04-11-2005, 07:14 PM
I've written a VB6 app that does some EXCEL OLE automation. And for the most part, I've been able to suppress any error messagest that pop up. However, I'm now getting the following error:



?Could not load an object because it is not available on this machine?

On this line of code:


Call XLApp1.ActiveWorkbook.SaveAs(sTarget, lTargetType, , , , , , _
xlLocalSessionChanges)

When I Create the XLApp1 object, I do the following to suppress the error conditions:


Set XLApp1 = New Excel.Application
XLApp1.Application.DisplayAlerts = mbVerbose
' Required!!!!! to disable macros and other things
XLApp1.EnableEvents = False
XLApp1.Visible = False
XLApp1.Application.DisplayAlerts = mbVerbose
XLApp1.AskToUpdateLinks = mbVerbose
XLApp1.AlertBeforeOverwriting = mbVerbose
XLApp1.PromptForSummaryInfo = mbVerbose

where mbVerbose = False Once you get through the message boxes that pop up, it actually does save ok. I cannot have any messge boxes pop up, period, as this will run unattented on a server. My app can be working with MS Excel 97-2003. Any and all suggestions are greatly appreciated.

Paleo
04-11-2005, 07:51 PM
Try to set:


On Error Resume Next
' Your code goes here
On Error GoTo 0

bitpusher
04-12-2005, 07:38 AM
Perhaps a more detailed explanation is required, as that "On error Resume Next" statement does not work.

The particular Excel file I'm trying to convert has some VBA code within it, that I do not have access to. Therefore, I cannot put the "On error resume next" within the Excel files VBA script.

Also, please keep in mind that the application I am writing is a Visual Basic 6 application.

Jacob Hilderbrand
04-12-2005, 08:01 AM
If you cannot change the code then you will not be able to supress the error message. In order to stop any error from being reported you would need to trap it at some point in the code (or ensure that it would never occur).

So to clarify, you are unable to try this:



On Error Resume Next
Call XLApp1.ActiveWorkbook.SaveAs(sTarget, lTargetType, , , , , , _
xlLocalSessionChanges)
On Error Goto 0

bitpusher
04-12-2005, 08:08 AM
I am capable of doing that, and tried exactly that.

However, I am not capable of accessing the VBA code that is within the Excel file that is being opened, and 'saved as' since it is locked. I believe the code within the Workbook file is calling up forms that don't exist. That is no concern of mine, I just want to open the Workbook file and SaveAs(), disregarding any messages that come up, and hopefully suppressing them.