Solved

2 questions about dialog boxes

Posted on 2004-08-17
1
663 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
brianb99999 earned 500 total points
ID: 11826355
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

628 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