Jump to content

embedded Excel issue


Bert
 Share

Recommended Posts

I have a script that embeds a excel object into a gui. Works fine. I've noticed that the embedded excel object will get corrupted from a visual aspect if another window gets on top of the GUI then removed. The displayed corruption can be removed if I scroll down to hide all the corruption, then scroll back. Not a good solution by any means. This is what it looks like if I were for example to open notepad, have that window have focus on top of the gui , then close notepad giving the GUI focus again.

$FileName = @ScriptDir&'\book1.xls'
If Not FileExists($FileName) Then
    MsgBox(0, "ERROR", "File not found")
    Exit
EndIf

;Basic GUI
$oExcelDoc = ObjGet($FileName); Get an Excel Object from an existing filename
If IsObj($oExcelDoc) Then
    $mainGUI = GUICreate("viewer", @DesktopWidth - 50, @DesktopHeight - 150, 10, 10, $WS_MINIMIZEBOX +$WS_SYSMENU);,  $WS_CLIPCHILDREN) 
    $GUI_ActiveX = GUICtrlCreateObj($oExcelDoc, 10, 70, @DesktopWidth - 75, @DesktopHeight - 260)
;------------------

;Turns off all command bars in excel to prevent user from making changes
    For $Bar In $oExcelDoc.CommandBars
        If $Bar.Enabled = True Then $Bar.Enabled = False
        If $Bar.Visible = True Then $Bar.Visible = False
    Next
    $oExcelDoc.Application.DisplayFormulaBar = False
    $oExcelDoc.Application.CommandBars("Shadow Settings").Visible = False
    $oExcelDoc.Application.DisplayScrollBars = True
    $oExcelDoc.Application.DisplayStatusBar = False

Is there a different way to embed the object so that it won't get corrupted when this happens? Or a way to refresh the screen?

Edited by Volly
Link to comment
Share on other sites

I don't know about a different embed method but why not just set it to always on top or send a $WM_PAINT message to redraw the window so there isn't any corruption. If the window is active then don't send, if it's not the active window get ready and when it's active again send the message,just my idea.

Link to comment
Share on other sites

  • 2 years later...

Hey there.

Updated code:

#include <WindowsConstants.au3>

$FileName = @ScriptDir&'\book1.xlsx'
If Not FileExists($FileName) Then
    MsgBox(0, "ERROR", "File not found")
    Exit
EndIf

;Basic GUI
$oExcelDoc = ObjGet($FileName); Get an excel Object from an existing filename
If IsObj($oExcelDoc) Then
    $mainGUI = GUICreate("viewer", @DesktopWidth - 50, @DesktopHeight - 150, 10, 10, $WS_MINIMIZEBOX +$WS_SYSMENU + $WS_CLIPCHILDREN)
    $GUI_ActiveX = GUICtrlCreateObj($oExcelDoc, 10, 70, @DesktopWidth - 75, @DesktopHeight - 260)
Else
    MsgBox(0,"","failed")
EndIf
;------------------

;Turns off all command bars in excel to prevent user from making changes
For $Bar In $oExcelDoc.CommandBars
    If $Bar.Enabled = True Then $Bar.Enabled = False
    If $Bar.Visible = True Then $Bar.Visible = False
Next
$oExcelDoc.Application.DisplayFormulaBar = False
$oExcelDoc.Application.CommandBars("Shadow Settings").Visible = False
$oExcelDoc.Application.DisplayScrollBars = True
$oExcelDoc.Application.DisplayStatusBar = False

GUISetState()

While 1
    Sleep(500)
WEnd

Any hints as to make this work without the toolbars and so forth? Just the cells...

Regards,

footswitch

Link to comment
Share on other sites

  • 3 months later...
  • 2 months later...

This, in VBA, make the Excel to show only the grid cells: Application.DisplayFullScreen = True

I added the line "$oExcelDoc.Application.DisplayFullScreen = True" and got a error from Autoit. Not sure why.

Add "$oExcelDoc.Application.DisplayFullScreen = True" before Guictrlcreateobj is called

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...