Jump to content

phanan

Members
  • Posts

    8
  • Joined

  • Last visited

phanan's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thanx for suggesting me about COM commands (this is first time i heard about this) For MSDN, to select a cell we use: $oExcel.Application.ActiveSheet.Range("A1").Select But how can we select all cell (juzt similar to Ctrl A)? Can u help me thix?
  2. Hi everyone! I hav a script which used some ControlSend commands to send something (Ctrl a, Ctrl c, Shift F11 & Ctrl v) to the Excel Book. It works, but sometimes it does not work and I dont really understand. I searched a lot, and got information about this problem, but it juzt happen only to the Cezch keyboards. Here I use English keyboard I post an example code here. So can anyone help me to solve this or suggest a new solution to make Select (Ctrl a), Copy (Ctrl c), Create New Sheet (Shift F11) & Paste (Ctrl v)? #include <Excel.au3> $oExcel = _ExcelBookNew() for $i = 1 to 20 step 1 for $j = 1 to 10 step 1 _ExcelWriteCell($oExcel, "x", $i, $j) Next Next ControlSend("Microsoft Excel - Book1", "", "", "^a") ControlSend("Microsoft Excel - Book1", "", "", "^c") ControlSend("Microsoft Excel - Book1", "", "", "+{F11}") ControlSend("Microsoft Excel - Book1", "", "", "^v") ;"[CLASS:EXCEL7; INSTANCE:1]"
  3. So instead of using Send(), I used ControlSend(). Thanx for ur contribution
  4. Thanx everyone, I juzt hav found the solution for thix. Thanx for joining my ques.
  5. @Melba23: cauze im new to this forum so I do not know this code tag function. thanx for ur recommend Here is my code (mayb a little hard to see ). Thiz code used to calculate the Call Setup Time of MS1 & MS2 from the Log File *.FMT #include <Excel.au3> Dim $oExcel,$sRangeOrRow, $iColumn, $sField, $sCriteria,$i $name = InputBox("Input Form","ENTER THE NAME OF UR LOG FILE"&@CRLF&@CRLF&"Ex: Ur logfile is Buu_dien_HCM.fmt. Then juzt enter Buu_dien_HCM in the line below") $path = "C:Temp"&$name&".fmt" $vipsave = "C:Temp"&$name $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 1 $oExcel.Workbooks.OpenText($path, _ 437, _ ; Origin 1, _ ; StartRow 1, _ ; DataType = x1Delimited 1, _ ; TextQualifier = x1DoubleQuote False, _ ; ConsecutiveDelimiter True, _ ; Tab False, _ ; Semicolon True, _ ; Comma False, _ ; Space False _ ; Other ) _ExcelBookSaveAs($oExcel, $vipsave, "xls", 0, 1) ; Save file, overwrite existing file if necessary ; #FUNCTION# ==================================================================================================================== ; Name...........: _ExcelFilter ; Description ...: Applies a filter to an excel file. ; Syntax.........: _ExcelFilter($oExcel,$sRangeorRow, $iColumn, $sField, $sCriteria) ; Parameters ....: $oExcel - An Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew() ; $sRangeOrRow - The range in A1 format, or a row number for R1C1 format ; $iColumn - The specified column number for R1C1 format (default = 1) ; $sField- the field no. where filter is to be applied. ; $sCriteria- the criteria for filter is to be applied. For e.g filter by country name "India". ; Return values .: Success - Returns 1 ; Failure - Returns 0 and sets @error on errors: ; @error=1 - Specified object does not exist ; @error=2 - Row or column invalid ; @extended=0 - Row invalid ; @extended=1 - Column invalid ; Author ........: Manjish Naik (naikma@gmail.com) ; Modified.......: None as yet ; Remarks .......: None ; Related .......: ; Link ..........; ; Example .......; _ExcelFilter($oExcel,1,2,2,"Amit Ravindra,Patil"), this filters out all entries except the one having "Manager Name" as "Amit Ravindra,Patil". ; The "manager name" is second filter field located at 1 row and 2nd column, hence $sField=2. ; =============================================================================================================================== Func _ExcelFilter($oExcel, $sRangeOrRow, $iColumn, $sField, $sCriteria) If Not StringRegExp($sRangeOrRow, "[A-Z,a-z]", 0) Then If $sRangeOrRow < 1 Then Return SetError(2, 0, 0) If $iColumn < 1 Then Return SetError(2, 1, 0) $oExcel.ActiveSheet.Cells($sRangeOrRow, $iColumn).Select $oExcel.selection.Autofilter($sField, $sCriteria) Else $oExcel.ActiveSheet.Range($sRangeOrRow).Select $oExcel.selection.Autofilter($sField, $sCriteria) EndIf EndFunc ;==>_ExcelFilter _ExcelFilter($oExcel,1,2,2,"MS1") _ExcelFilter($oExcel,1,6,6,"Call Setup") Send("{CTRLDOWN}") Send("a") Send("c") Send("{CTRLUP}") Send("{SHIFTDOWN}") Send("{F11}") Send("{SHIFTUP}") Send("{CTRLDOWN}") Send("v") Send("{CTRLUP}") Sleep(1000) _ExcelSheetActivate($oExcel,"Sheet1") $number=_ExcelWriteFormula($oExcel,"=Counta(R2C6:R500C6)",2,16) $no=_ExcelReadCell($oExcel,2,16) For $i=1 to $no Step 1 for $j=1 to 10 Step 1 _ExcelWriteFormula($oExcel,"=Left(R"&$i+1&"C8,11)",$i+1,13) _ExcelWriteFormula($oExcel,"=Mid(R"&$i+1&"C8,14,4)",$i+1,15) Next Next $result = 0 $count1 = 0 For $k=1 to $no Step 1 $setup=_ExcelReadCell($oExcel,$k+1,13) If $setup = " setup time" Then $count1 = $count1 + 1 $result=$result + _ExcelReadCell($oExcel,$k+1,15) EndIf Next _ExcelWriteCell($oExcel,$count1,2,16) $MS1=$result/$count1 Sleep(1000) _ExcelSheetActivate($oExcel,$name) _ExcelFilter($oExcel,1,2,2,"MS2") _ExcelFilter($oExcel,1,6,6,"Call Setup") Send("{CTRLDOWN}") Send("a") Send("c") Send("{CTRLUP}") Send("{SHIFTDOWN}") Send("{F11}") Send("{SHIFTUP}") Send("{CTRLDOWN}") Send("v") Send("{CTRLUP}") Sleep(1000) _ExcelSheetActivate($oExcel,"Sheet2") $number=_ExcelWriteFormula($oExcel,"=Counta(R2C6:R100C6)",2,16) $no=_ExcelReadCell($oExcel,2,16) For $i=1 to $no Step 1 for $j=1 to 10 Step 1 _ExcelWriteFormula($oExcel,"=Left(R"&$i+1&"C8,11)",$i+1,13) _ExcelWriteFormula($oExcel,"=Mid(R"&$i+1&"C8,14,4)",$i+1,15) Next Next $result = 0 $count2 = 0 For $k=1 to $no Step 1 $setup=_ExcelReadCell($oExcel,$k+1,13) If $setup = " setup time" Then $count2 = $count2 + 1 $result=$result + _ExcelReadCell($oExcel,$k+1,15) EndIf Next _ExcelWriteCell($oExcel,$count2,2,16) $MS2=$result/$count2 $round_MS1 = Round($MS1,2) $round_MS2 = Round($MS2,2) _ExcelSheetActivate($oExcel,$name) Send("{ESC}") ;_ExcelBookClose($oExcel,1,0) ;Close & Save If ($count1 <> 0) And ($count2 <> 0) Then MsgBox(0,"Call Setup Time (ms): "&$name,"MS1 = "&$round_MS1&@CRLF&"MS2 = "&$round_MS2) ElseIf ($count1 = 0) & ($count2 <> 0) Then MsgBox(0,"Call Setup Time (ms): "&$name,"MS1 = Unknown"&@CRLF&"MS2 = "&$round_MS2) Else MsgBox(0,"Call Setup Time (ms): "&$name,"MS1 = "&$round_MS1&@CRLF&"MS2 = Unknown") EndIf
  6. I hav uploaded my code by the Mediafire Link. So can u waste ur time to take a look on it? Thanx
  7. Thiz iz the link contain my code: http://www.mediafire.com/?69vo3c68q4w54i1 Hope to be helped by everyone. Thanx
  8. Hi everyone! Im very new to AutoIT I hav juzt written a simple code. This code is about saving the content of log file (*.fmt) to Excel, then filter, then doing some calculations. So when this code is running, i saw the Excel open, doing filter & doing calculation & give result So the Problem here is how to make all this process into background (mean no display the Excel Window, no display Calculation) and juzt give the Result only. Hope to be helped Thanx a lot
×
×
  • Create New...