s3nsei Posted September 28, 2010 Share Posted September 28, 2010 Hello guys,Please kindly help me, is there any way to read the selected row & column in Excel?I'm trying to format the font of selected cell in Excel, below is my noob script :===START===#include <Excel.au3>#include <File.au3>Opt("WinTitleMatchMode", 2)$sFilePath = @DesktopDir & "\test.xls"$Excel = "test"$oExcel = _ExcelBookAttach($sFilePath) WinActivate($Excel)_ExcelWriteCell($oExcel, "TEST", 1, 1) $Row = $oExcel.activesheet.row$Column = $oExcel.activesheet.column_ExcelFontSetProperties($oExcel,$Row , $Column, $Row, $Column, True, True, True)===END===My script is a totally disaster, if anyone know the answer, please kindly tell me.Thanks a lot. Link to comment Share on other sites More sharing options...
JoHanatCent Posted September 28, 2010 Share Posted September 28, 2010 (edited) ;===START=== #include <Excel.au3> #include <File.au3> Opt("WinTitleMatchMode", 2) $sFilePath = @DesktopDir & "\test.xls"; no need to duplicate all is in here $oExcel = _ExcelBookOpen($sFilePath, 1) ; 1= Visable 0 = Not Visable ;=== Testing to see if the file exist as per help file If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist - Shame on you!") Exit EndIf ;=== Done the testing bit _ExcelSheetActivate($oExcel, "sheet1") ; Open correct sheet WinActivate($oExcel) _ExcelWriteCell($oExcel, "TEST", 1, 1) ; The same as cell A1 $sRangeOrRowStart = 1 ; Can use as A1:A2 spesifing a range else it is seen as the first row number and the rest needs to be used ==>> $iColStart = 1 $iRowEnd = 1 $iColEnd = 1 $fBold = True $fItalic = True $fUnderline = True _ExcelFontSetProperties($oExcel, $sRangeOrRowStart, $iColStart, $iRowEnd, $iColEnd, $fBold, $fItalic, $fUnderline ) sleep(2000) _ExcelBookClose($oExcel, 1, 0); 1 = Save before closing ;===END===Hi Here is a working script to start off with: Edited September 28, 2010 by JoHanatCent Link to comment Share on other sites More sharing options...
SeF Posted September 28, 2010 Share Posted September 28, 2010 $SelectedCells = $oExcel.Application.Selection.Address(False, False) _ExcelFontSetProperties($oExcel, $SelectedCells, "", "", "", True, True, True ) Will change the font of all selected cell Any questions, fell free to ask! Link to comment Share on other sites More sharing options...
s3nsei Posted September 29, 2010 Author Share Posted September 29, 2010 Dear all,Thank you so much for your answer and attention, love you all.. Now, i'm wondering where'd you get below underlined parameter ? $oExcel.Application.Selection.Address(False, False)Any link / reference is much appreciated.Thanks a lot Link to comment Share on other sites More sharing options...
SeF Posted September 29, 2010 Share Posted September 29, 2010 (edited) Dear all,Thank you so much for your answer and attention, love you all.. Now, i'm wondering where'd you get below underlined parameter ? $oExcel.Application.Selection.Address(False, False)Any link / reference is much appreciated.Thanks a lot Google + MSDN site Application = http://msdn.microsoft.com/en-us/library/bb210077(v=office.12).aspx"Represents the entire Microsoft Excel application."Selection = http://msdn.microsoft.com/en-us/library/bb214188(v=office.12).aspxApplication's property.Address = http://msdn.microsoft.com/en-us/library/bb213510(v=office.12).aspxRange's property.MSDN site is a good referente for Microsoft's softwares. You can play around with some good stuffs from there. Edited September 29, 2010 by SeF Link to comment Share on other sites More sharing options...
s3nsei Posted October 7, 2010 Author Share Posted October 7, 2010 Good day all, Does anyone have any idea how to fix below error? Please kindly assist, thanks a lot! ERROR MESSAGE : >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\jkt-willyl\My Documents\Autoit\Share\LOG.au3" C:\Program Files\AutoIt3\Include\Excel.au3 (410) : ==> The requested action with this object has failed.: $oExcel.Application.DisplayAlerts = $fDisplayAlerts $oExcel.Application^ ERROR >Exit code: 1 Time: 1060.214 Link to comment Share on other sites More sharing options...
Juvigy Posted October 11, 2010 Share Posted October 11, 2010 seems that $oExcel is not an object. Check with IsObj function. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now