Solved

2 questions about dialog boxes

Posted on 2004-08-17
1
659 Views
Last Modified: 2008-01-09
I have this dialog box saying "There was an error opening this document/ the file is damaged and could not be repaired" it has an Adobe Acrobat title bar. This is the code in which the error appeared:
Sub pdfprocess()
    On Error GoTo pdferrorhandler
    Dim x
    x = PrintFile(fileloc)
    PrintDetector
pdferrorhandler:
End Sub

Private Function PrintFile(strFileName As String) As Boolean
    Const SW_HIDE = 0
    Const SW_MAXIMIZE = 3
    Const SW_MINIMIZE = 6
    Const SW_RESTORE = 9
    Const SW_SHOW = 5
    Const SW_SHOWDEFAULT = 10
    Const SW_SHOWMAXIMIZED = 3
    Const SW_SHOWMINIMIZED = 2
    Const SW_SHOWMINNOACTIVE = 7
    Const SW_SHOWNA = 8
    Const SW_SHOWNOACTIVATE = 4
    Const SW_SHOWNORMAL = 1
    Const ERROR_OOM = 0
    Const ERROR_FILE_NOT_FOUND = 2
    Const ERROR_PATH_NOT_FOUND = 3
    Const ERROR_BAD_FORMAT = 11
    Const SE_ERR_ACCESSDENIED = 5
    Const SE_ERR_ASSOCINCOMPLETE = 27
    Const SE_ERR_DDEBUSY = 30
    Const SE_ERR_DDEFAIL = 29
    Const SE_ERR_DDETIMEOUT = 28
    Const SE_ERR_DLLNOTFOUND = 32
    Const SE_ERR_FNF = 2
    Const SE_ERR_NOASSOC = 31
    Const SE_ERR_OOM = 8
    Const SE_ERR_PNF = 3
    Const SE_ERR_SHARE = 26
    On Error GoTo PrintFileError
    ShellExecute Me.hwnd, "print", strFileName, vbNull, vbNull, SW_SHOWMINIMIZED
    DoEvents
    PrintFile = True
    Exit Function
PrintFileError:
    PrintFile = False
    'MsgBox "Error #" & Err.Number & vbCrLf & Err.Description, vbCritical, "Error Printing File"
    Exit Function
End Function

I also have this dialog box saying "print titles must be contiguous and complete rows or columns" it has a Visual Basic title bar. This is the code in which the error appeared:
Sub excelprocess()
    Dim i As Integer
    On Error GoTo xlserrorhandler
    Set excel_app = New Excel.Application
    Set excel_wb = excel_app.Workbooks.Open(fileloc, 0)
    DoEvents
    For i = 1 To excel_wb.Worksheets.Count
        Set excel_ws = excel_wb.Worksheets(i)
        excel_ws.Visible = True
        excel_ws.Columns.Hidden = False
        excel_ws.Rows.Hidden = False
        excel_ws.PrintOut
        DoEvents
    Next i
    PrintDetector
    Set excel_ws = Nothing
    excel_wb.Close False
    Set excel_wb = Nothing
    excel_app.Quit
    Set excel_app = Nothing
    Exit Sub
xlserrorhandler:
    errorflag = 1
    Set excel_ws = Nothing
    excel_wb.Close False
    Set excel_wb = Nothing
    excel_app.Quit
    Set excel_app = Nothing
    Exit Sub
End Sub

The question is how to disable these dialog boxes through the code?
0
Comment
Question by:4ceReconSniper
1 Comment
 
LVL 5

Accepted Solution

by:
brianb99999 earned 500 total points
Comment Utility
1.
The bug dialog is being shown and controlled from the program you are calling - I think it would be very hard to disable this (maybe using Spy++ to get the handle of the message and then intercepting it somehow).

2.
You need to debug to see exactly what line the error is occuring on.  If it is a problem in excel then see 1 above, otherwise try adding into
xlserrorhandler:
err.clear
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now