Is this possible?
Excel Window in a GUI
#1
Posted 31 August 2006 - 11:20 PM
Is this possible?
#2
Posted 31 August 2006 - 11:25 PM
just serach "excel" in help
found these two, so i know it can be done in the same was as IE
Here is an example that 'automates' Microsoft Excel: $oExcel = ObjCreate("Excel.Application") ; Create an Excel Object $oExcel.Visible = 1 ; Let Excel show itself $oExcel.WorkBooks.Add ; Add a new workbook $oExcel.ActiveWorkBook.ActiveSheet.Cells(1,1).Value="test" ; Fill a cell sleep(4000) ;See the results for 4 seconds $oExcel.ActiveWorkBook.Saved = 1 ; Simulate a save of the Workbook $oExcel.Quit ; Quit Excel oÝ÷ Ù©Ýjëh×6 $oExcel = ObjCreate("Excel.Application") $oExcel.visible =1 $oExcel.workbooks.add With $oExcel.activesheet .cells(2,2).value = 1 .range("A1:B2").clear Endwith $oExcel.quit
8)
Edited by Valuater, 31 August 2006 - 11:25 PM.
#3
Posted 31 August 2006 - 11:36 PM
EDIT: Just like in the example. When ran you don't get all of the tool bars and all of the other fun micro$oft stuff.
Edited by strate, 31 August 2006 - 11:38 PM.
#4
Posted 01 September 2006 - 06:49 AM
He's a test script I wrote about a year ago, testing the ActiveX GUI functions:Thanks I know how to do that though. I don't want Excel to open entirely I just want the window. So that it feels like my script has a spreadsheet in it.
EDIT: Just like in the example. When ran you don't get all of the tool bars and all of the other fun micro$oft stuff.
Before you run it, change line 14 with a filename of an existing excel sheet.
#include <GUIConstants.au3> ; ; Embedding an Excel document inside an AutoIt GUI ; ; Limitations: ; ; 1. Integrating the GUI Menu with the Objects Menu does not work. ; (they have seperate menu bars) ; ; Initialize my error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $FileName=@ScriptDir & "\Worksheet.xls" if not FileExists($FileName) then Msgbox (0,"Excel File Test","Can't run this test, because it requires an Excel file in "& $FileName) Exit endif $oExcelDoc = ObjGet($FileName) ; Get an Excel Object from an existing filename if IsObj($oExcelDoc) then ; Create a simple GUI for our output GUICreate ( "Embedded ActiveX Test", 640, 580, (@DesktopWidth-640)/2, (@DesktopHeight-580)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPCHILDREN ) ; Create a test File Menu $GUI_FileMenu = GUICtrlCreateMenu ("&File") $GUI_FileNew = GUICtrlCreateMenuitem ("&New" ,$GUI_FileMenu) $GUI_FileSave = GUICtrlCreateMenuitem ("&Save" ,$GUI_FileMenu) $GUI_FileSaveAs = GUICtrlCreateMenuitem ("Save As..." ,$GUI_FileMenu) $GUI_FileSepa = GUICtrlCreateMenuitem ("" ,$GUI_FileMenu) ; create a separator line $GUI_FileExit = GUICtrlCreateMenuitem ("E&xit" ,$GUI_FileMenu) $GUI_ActiveX = GUICtrlCreateObj ( $oExcelDoc, 30, 90 , 400 , 300 ) GUISetState () ;Show GUI $oExcelDoc.Windows(1).Activate ; I don't think this is necessary. ; GUI Message loop While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE or $msg = $GUI_FileExit ExitLoop Case $msg = $GUI_FileSave $oExcelDoc.Save ; Save the workbook Case $msg = $GUI_FileSaveAs $NewFileName=FileSaveDialog("Save Worksheet as",@scriptdir,"Excel Files (*.xls)") if not @error and $NewFileName <> "" Then $oExcelDoc.SaveAs($NewFileName) ; Save the workbook under a different name EndIf EndSelect Wend GUIDelete () ; Don't forget to close your workbook, otherwise Excel will stay in memory after the script exits ! $oExcelDoc.Close ; Close the Excel workbook EndIf Exit ; This is my custom error handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc
Excel starts in this script with the 'default' toolbars. To change the excel toolbars or other fancy stuff, you might need to read the VBA help in Excel itself. Those are properties of the Excel Application, not AutoIt.
Regards,
-Sven
#5
Posted 01 September 2006 - 10:41 AM
You can see integrated in ptrex's GUI for SQl; [sticky in scrips and scraps)]
SQLite_Gui.au3This example now shows an integrated EXCEL object, which can be used to export data form the LV to EXCEL
Also in my SQL in my signature (in SQL GUIView scripts)
Best ,Randall
#6
Posted 01 September 2006 - 01:50 PM
Can somebody show meHi,
You can see integrated in ptrex's GUI for SQl; [sticky in scrips and scraps)]
SQLite_Gui.au3
Also in my SQL in my signature (in SQL GUIView scripts)
Best ,Randall
How to i save the values / contents of a cell to a text file from the embeded Excel Object ?
#7
Posted 01 September 2006 - 03:23 PM
This shows retrieving the used range to a 2D array; then save the array to the file; or an individual item?
Best, Randall
Case $msg = $GUI_FileRead $s_GUIBookName = $oExcelDoc.Application.ActiveWorkBook.fullname $Ar_var = $oExcelDoc.Application.activesheet.UsedRange.value _ArrayViewText($Ar_var, '$s_GUIBookName='&$s_GUIBookName)
[PS or substtitute "usedrange" for a named or cell-defined range or cell, to get individual cell etc]
Attached Files
Edited by randallc, 01 September 2006 - 03:27 PM.
#8
Posted 01 September 2006 - 06:02 PM
This is great and almost what I need. I do need to get rid of the tool bars.... hopefully I can figure this out. Thank you.He's a test script I wrote about a year ago, testing the ActiveX GUI functions:
Before you run it, change line 14 with a filename of an existing excel sheet.
AutoIt#include <GUIConstants.au3> ; ; Embedding an Excel document inside an AutoIt GUI ; ; Limitations: ; ; 1. Integrating the GUI Menu with the Objects Menu does not work. ; (they have seperate menu bars) ; ; Initialize my error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $FileName=@ScriptDir & "\Worksheet.xls" if not FileExists($FileName) then Msgbox (0,"Excel File Test","Can't run this test, because it requires an Excel file in "& $FileName) Exit endif $oExcelDoc = ObjGet($FileName) ; Get an Excel Object from an existing filename if IsObj($oExcelDoc) then ; Create a simple GUI for our output GUICreate ( "Embedded ActiveX Test", 640, 580, (@DesktopWidth-640)/2, (@DesktopHeight-580)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPCHILDREN ) ; Create a test File Menu $GUI_FileMenu = GUICtrlCreateMenu ("&File") $GUI_FileNew = GUICtrlCreateMenuitem ("&New" ,$GUI_FileMenu) $GUI_FileSave = GUICtrlCreateMenuitem ("&Save" ,$GUI_FileMenu) $GUI_FileSaveAs = GUICtrlCreateMenuitem ("Save As..." ,$GUI_FileMenu) $GUI_FileSepa = GUICtrlCreateMenuitem ("" ,$GUI_FileMenu) ; create a separator line $GUI_FileExit = GUICtrlCreateMenuitem ("E&xit" ,$GUI_FileMenu) $GUI_ActiveX = GUICtrlCreateObj ( $oExcelDoc, 30, 90 , 400 , 300 ) GUISetState () ;Show GUI $oExcelDoc.Windows(1).Activate ; I don't think this is necessary. ; GUI Message loop While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE or $msg = $GUI_FileExit ExitLoop Case $msg = $GUI_FileSave $oExcelDoc.Save ; Save the workbook Case $msg = $GUI_FileSaveAs $NewFileName=FileSaveDialog("Save Worksheet as",@scriptdir,"Excel Files (*.xls)") if not @error and $NewFileName <> "" Then $oExcelDoc.SaveAs($NewFileName) ; Save the workbook under a different name EndIf EndSelect Wend GUIDelete () ; Don't forget to close your workbook, otherwise Excel will stay in memory after the script exits ! $oExcelDoc.Close ; Close the Excel workbook EndIf Exit ; This is my custom error handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc
Excel starts in this script with the 'default' toolbars. To change the excel toolbars or other fancy stuff, you might need to read the VBA help in Excel itself. Those are properties of the Excel Application, not AutoIt.
Regards,
-Sven
#9
Posted 01 September 2006 - 06:13 PM
Adding:This is great and almost what I need. I do need to get rid of the tool bars.... hopefully I can figure this out. Thank you.
With $oExcelDoc .CommandBars("Full Screen").Visible = False .CommandBars("Standard").Enabled = False .CommandBars("Formula Bar").Enabled = False .CommandBars("Formatting").Enabled = False .CommandBars("Worksheet Menu Bar").Enabled = False EndWith
After you create the Obj control will remove all of the needed bars except the formula bar which i don't need either..... I'll update if i find anything...
#10
Posted 01 September 2006 - 06:21 PM
Thank you everyone that helped.
Consider this a closed/resolved topic.
#include <GUIConstants.au3> ; ; Embedding an Excel document inside an AutoIt GUI ; ; Limitations: ; ; 1. Integrating the GUI Menu with the Objects Menu does not work. ; (they have seperate menu bars) ; ; Initialize my error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ;~ $FileName=@ScriptDir & "\Worksheet.xls" $FileName = 'G:\Packaging\Process Sheets\136041.xls' if not FileExists($FileName) then Msgbox (0,"Excel File Test","Can't run this test, because it requires an Excel file in "& $FileName) Exit endif $oExcelDoc = ObjGet($FileName) ; Get an Excel Object from an existing filename if IsObj($oExcelDoc) then GUICreate ( "Embedded ActiveX Test", 640, 580, (@DesktopWidth-640)/2, (@DesktopHeight-580)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPCHILDREN ) $GUI_ActiveX = GUICtrlCreateObj ( $oExcelDoc, 1, 95 , 400 , 300 ) With $oExcelDoc .CommandBars("Full Screen").Visible = False .CommandBars("Standard").Enabled = False .CommandBars("Formatting").Enabled = False .CommandBars("Worksheet Menu Bar").Enabled = False .Application.DisplayFormulaBar = False EndWith GUISetState () ;Show GUI ; GUI Message loop While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE;or $msg = $GUI_FileExit ExitLoop EndSelect Wend GUIDelete () ; Don't forget to close your workbook, otherwise Excel will stay in memory after the script exits ! $oExcelDoc.Close (0) ; Close the Excel workbook - Save prompt will not open EndIf Exit ; This is my custom error handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc
#11
Posted 12 January 2009 - 08:32 PM
With $oExcelDoc .CommandBars("Full Screen").Visible = False .CommandBars("Standard").Enabled = False .CommandBars("Formatting").Enabled = False .CommandBars("Worksheet Menu Bar").Enabled = False .Application.DisplayFormulaBar = False EndWith
It's not removing the toolbars in excel 2007. In fact the toolbar is partially covering the sheet.
But my objective is to get rid of the tools bars anyway
Thanks,
Kenny
#12
Posted 12 January 2009 - 11:19 PM
Does anyone know of a freeware tool to create the XML file.
And more importantly how I can apply the XML using the above?
Thanks,
Kenny
#13
Posted 09 October 2011 - 02:51 AM
Anyone know how to get ride of the Excel 2007 tool bar?
#14
Posted 14 November 2012 - 08:26 PM
Any suggestions?

#15
Posted 14 November 2012 - 08:34 PM
Please don't necro post...this post predates Windows XP SP3, that's how old it is.
How to ask questions the smart way!
Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.
Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.
_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users








