Supress dialog box while tracing High Resolution bitmap


I am developing a VBA macro to trace bitmaps in a folder. For some high-resolution bitmaps, I see dialog box showing message like:

Power Trace: Bitmap size is too large and must be reduced.

I am given two options (1). Reduce bitmap (2). Keep original size

I want this box to be suppressed with the second option to keep the image to original size. Is it possible?

Kind Regards.

Parents
No Data
Reply
  • Not possible using standard Corel VBA facilitiies, but possible using some tricks:

    It is not complicate to use API (FindWindow, FindWindowEx and SendMerssage) to find the window you presented in the attached picture, the button having the caption "Keep original size" and automatically press it using SendMessage. But unfortunately Corel VBA completely stops when such a window is displayed... Even if Corel VBA can deal with API calls, it is useless in such a case. I mean to directly use it.

    In order to deal with that issue you must use a second application. Another Corel session, an Excel/Word session, .NET, C# having a form with a Timer on it looking for the specific window and pressing the necessary button when it appears. Again, if you follow this approach, unfortunately, VBA does not have in the IDE ToolBox a Timer control. So you must build it using SetTimer and KillTimer APIs...

    If what I say is not Chinese for you I would suggest to try it. Theoretically it has to work!

    If you do not dare to try and really need it, I will help you creating such an Excel .xlsm file, able to solve the problem. You can automate the Excel file opening, the form keeping the timer loading and its closing. It can be done even with a call in the function doing the tracing. But I will do that in a second step. You firstly must create a way to look for that specific button and automatically press it when appears. I am sure it is possible in the way I have just explained.

    Besides all that, Corel is tricky in the way of sending such messages. For a specific (big) bitmap width (height) limitation it has a "Cancel" button instead of "Keep original size" and you must determine which is that limit. Doing that you can 'instruct' the application to warn in such a case...

Children
  • I found some time and I created (and tested) the Excel workbook able to solve your problem exactly as I explained in my previous comment..

    You can download the file from here. It will stay there only 7 days...

    What it does and how it is good to be used:

    1. Please download and save the workbook somewhere in your computer and keep in mind its full path.

    2. In order to be sure that Excel allows its maro to run, add its folder path to the Excel Trusted locations.

    3. You can manually open it and press the button "Start Timer" from the first page.

    4. Go in Corel and use your code. When the problematic window will appear, the necessary button will automatically be pressed. Going back to Excel workbook, you will see that the form will count the number of button pressing. In the label "Working times".

    You can open that workbook and show the necessary form directly from Corel, using VBA. If the workbook will be already open, the next code will find it and do what is necessary to be done. If not open, it will open it and do the same.

    In order to work, the .gms keeping the code must have a reference to "Microsoft Excel xx Object Library". Where xx is the Ofice version. In my case, tested on 16.0 version. The reference is add in IDE Tools -> References... and check the appropriate reference according to your Office installation version.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    Option Explicit
    
    Sub RunExlMacro()
      Dim Exl As Excel.Application, w As Workbook, WTimer As Workbook, Pg As Worksheet
      Dim shortName As String, WorkPath As String, boolFound As Boolean
        WorkPath = "F:\VBA Excel\SolveCorelTRACE.xlsm"
        shortName = Right(WorkPath, Len(WorkPath) - InStrRev(WorkPath, "\"))
         'Debug.Print shortName: Stop
        
        On Error Resume Next
         Set Exl = GetObject(, "Excel.Application")
         If Err.Number <> 0 Then
            Err.Clear
            On Error GoTo 0
            GoTo OpenSession
         Else
            On Error GoTo 0
            For Each w In Exl.Workbooks
                If w.name Like shortName Then
                    Set WTimer = w: boolFound = True: Exit For
                End If
            Next
         End If
         If boolFound Then GoTo ExcelWorkbookDefined
    OpenSession:
         Set Exl = CreateObject("Excel.Application")
         Set WTimer = Exl.Workbooks.Open(WorkPath)
         Exl.Visible = True
         'Take focus on Corel application:
         AppActivate "CorelDRAW"
    ExcelWorkbookDefined:
        'Call the procedure launching the necessary form:
        Exl.Run shortName & "!ShowForm"
        
    End Sub
    

    Please change "WorkPath" to be your workbook full path. My code calls the 'ShowForm' procedure. I also created 'FormUnload' procedure which can be called of the end of your code... I would let you do that, if you do not want to let Excel continuously working with the form keeping the timer...

    Please test it and I would like some feedback. I do not need such a code, but I took it like a challenge...

    If you do not understand something or need some more clarifications, do not hesitate to ask.

    This method can be extrapolated to any such a window. That's why is good to understand it, I think...