Jump to content

Simple script to change value


p666
 Share

Recommended Posts

Hello everyone!

I need а script who change the first column of each row in table ( Master Account)!

Its content 4753 (value) and I need to change to 4797(value) !

And because I have over 20,000 rows to change I need a script to do it ?!!?

Attach and image with the table itself!

Thanks for any help !

Doc1.docx

Link to comment
Share on other sites

Can't you just open Word and do a Find/ReplaceAll on it?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

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 editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I'm not going to open the attachment, but if it's on a grid, you can get all the grid collections, and then loop through the rows/columns as needed...google is your friend.

example:

#include <Word.au3>
#include <Array.au3>
$oWord = _WordCreate ( "C:Userssample.doc", False, True )
$oTables = $oWord.Activedocument.Tables
For $oTable In $oTables
 $bSkipTable = False
 $oColumns = $oTable.Columns
 $oRows = $oTable.Rows
 If $oColumns.count = 5 Then
  $sTableText = ""
  For $j = 1 To $oRows.Count
   $cels = $oTable.Rows($j).Cells
   $sRowText = ""
   $bSkipRow = False
   For $i = 1 To $oColumns.Count
    If $cels.count <> 5 Then
     $bSkipRow = True
     ExitLoop
    EndIf
    $sText = $cels($i).Range.Text
    If $j = 1 And $i = 1 Then
     If Not StringInStr ( $sText, "Step" ) Then
      $bSkipTable = True
      ExitLoop
     Else
      ExitLoop
     EndIf
    EndIf
    $sText = StringReplace ( $sText, Chr(7), "" )
    $sText = StringReplace ( $sText, "'", "''" )
    $sText = StringStripWS ( $sText, 7 )
    $sText = StringReplace ( $sText, @CR, "' & @CRLF & '" )
    If 2 <= $i And $i <= 3 Then
     If StringLen ( $sRowText ) > 0 Then
      $sRowText &= ",'" & $sText & "'"
     Else
      $sRowText = "'" & $sText & "'"
     EndIf
    EndIf
   Next
   If StringLen ( $sRowText ) > 0 Then
    If StringLen ( $sTableText ) > 0 Then
     If $j = $oRows.Count Then
      ; Last row, finish array
      $sTableText &= "[" & $sRowText & "]]"
     Else
      ; middle row, add & _
      $sTableText &= "[" & $sRowText & "], _ " & @CRLF
     EndIf
    Else
     ; First Row, add array sum
     $sTableText = "Dim $aVTPData[" & $oRows.Count - 1 & "][2]=[[" & $sRowText & "], _ " & @CRLF
    EndIf
   Else
    If $bSkipRow Then
     $sTableText &= "['','']]"
    EndIf
   EndIf
   If $bSkipTable Then ExitLoop
  Next
  ConsoleWrite ( $sTableText & @CRLF  )
 EndIf
Next
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Thаnks to your replay jdelaney !

Yes my data is in grid , and I only have to change each rows in firs colomn in this grid !Тo move between regular use the 'down' button!

And for each value that is constant to each line I must replace it with another that is also constant !

Аny suggestions would be helpful !

Regards

Link to comment
Share on other sites

well, my sample has what you need. You will have to lookup how to modify data in a cell, i was just stripping data in the sample. This forum is a good place for specific questions, not to have code written for you...though i just basically wrote it for you.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Ok here is my code for now:

~ start script

Global $Name1 = "PCC"
$row = InputBox("Message","How many rows to change?","","")
Sleep(5000)
Global $Name2 = ""
For $i = 1 to $row
_Run()
Next

Func _Run()
WinWaitActive($Name2)
Send("ctrl^a ")
Send("{DOWN}")
WinWaitActive("")
Send("{DOWN}")
EndFunc ;==>_Run

And now i need to insert only the values to change !

ps: I was only beginner in AutoIt !

Regards

Link to comment
Share on other sites

I'd suggest not going the route you have posted above, and instead use the VBA/API for Word, like what I have posted.

Sends tend to get messy, where sometimes the send isn't registered by the app, but the API is consistent.

Use the helpfile for functions that start with _word

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

well then, that is much different :)...use the window info tool (autoit tool) to get the grid's class type. Paste in the details on your next post

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Ok here is it ?

>>>> Window <<<<

Title: Pervasive Control Center

Class: SWT_Window0

Position: -8, -8

Size: 1382, 744

Style: 0x97CF0000

ExStyle: 0x00100100

Handle: 0x000205AE

>>>> Control <<<<

Class: SysListView32

Instance: 1

ClassnameNN: SysListView321

Name:

Advanced (Class): [CLASS:SysListView32; INSTANCE:1]

ID: 263320

Text:

Position: 34, 70

Size: 1298, 587

ControlClick Coords: 265, 26

Style: 0x56311041

ExStyle: 0x00100200

Handle: 0x00040498

>>>> Mouse <<<<

Position: 299, 138

Cursor ID: 0

Color: 0xFFFFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

pjoints

Thanks for helping me!

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...