Solved

2 questions about dialog boxes

Posted on 2004-08-17
1
662 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

734 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