Solved

2 questions about dialog boxes

Posted on 2004-08-17
1
661 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
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Excel VBA combine two working workbooks 8 60
Determine Range to Select 5 53
How to compare ms sql hashbytes results within vb6 5 85
Added a column screws up code 5 63
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

830 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