Jump to content
anoig

Need help debugging _arrayadd function

Recommended Posts

anoig

Hi all, 

First, I want to give a huge shout-out to the community. I'm completely self-taught, and have never had to actually ask a question before because the forum is that good at answering questions and explaining things. However, I'm kind of stumped here, and I've been stuck on this problem for almost a full day.

I'm working on a script to populate drafts of deeds at work. I have the main GUI and  a function (ctrl($n) and read()) for adding fields to find and data to replace it with to an array for later use with _word_docfindreplace. All of that works. However, due to the way I have the forms set up, I need to create additional fields and info based on the data that's there. Specifically, if there's only one buyer, I need to add the field [Buyer1&2] and the data in $aArray_Base for [Buyer 1]. I also need to add a field [Buyer 2] and have a blank data set in the next column over in the array, and I need to do the same for the Seller. To this end, the function parties() sets boolean variables $2buyers and $2sellers accordingly. Then, I have buyers() and sellers() to populate the data. 

The problem that I'm running into is that each function works... when ONLY the buyer 1 name field is filled, and when ONLY the seller 1 field is filled.

So if I fill Buyer 1 Name and save it, the data is populated correctly. But when I fill Buyer 1 and Seller 1 name, only the buyer 1 data populates correctly. Worse, when I fill several fields, neither populate correctly. I have no idea why this happens. I've added messageboxes to debug throughout the entire process and can't pinpoint what's causing the issue. The entire script is below. The function(s) in question are buyers() and sellers(). Only Sellers() has messageboxes throughout.

Can someone help walk me through what might be causing this and help me find a solution? Thanks a ton in advance, and sorry for the wall of text.

-Anoig

Spoiler
#include <ButtonConstants.au3> ;AutoIT plugins
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <Word.au3>
#include <ComboConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Randy\Downloads\koda_1.7.3.0\Forms\KNDS.kxf
$KNDS = GUICreate("KNDS DocPrep Wizard", 727, 507, 540, 193)
$MainPage = GUICtrlCreateTab(8, 40, 708, 424)
$TabSheet1 = GUICtrlCreateTabItem("Property")
$Property = GUICtrlCreateGroup("Legal Description", 32, 80, 657, 153)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$InputLegal = GUICtrlCreateEdit("", 40, 96, 641, 129, $ES_WANTRETURN, 0)
GUICtrlSetTip(-1, "Full legal description from Schedule A of Title Commitment")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Buyer = GUICtrlCreateTabItem("Buyer")
$Buyer1Group = GUICtrlCreateGroup("Buyer 1", 24, 72, 329, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$inputbuyer1 = GUICtrlCreateInput("", 120, 104, 217, 22)
GUICtrlSetTip(-1, "Bob Buyer, LLC")
$Buyersingle = GUICtrlCreateRadio("Single", 32, 136, 57, 17)
$BuyerMarried = GUICtrlCreateRadio("Married", 32, 160, 65, 17)
$BuyerLLC = GUICtrlCreateRadio("LLC", 32, 184, 57, 17)
$BuyerInc = GUICtrlCreateRadio("Inc.", 32, 208, 49, 17)
$inputbuyerentitystate = GUICtrlCreateInput("", 272, 208, 73, 22)
GUICtrlSetTip(-1, "Write out state name, e.g. Texas")
$Buyer1label = GUICtrlCreateLabel("Buyer 1 Name:", 32, 104, 75, 18)
$labelbuyerentitystate = GUICtrlCreateLabel("State (only if LLC or Inc.):", 136, 208, 127, 18)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Buyer2Group = GUICtrlCreateGroup("Buyer 2", 368, 72, 321, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Buyer2label = GUICtrlCreateLabel("Buyer 2 Name:", 376, 104, 75, 18)
$InputBuyer2 = GUICtrlCreateInput("", 464, 104, 209, 22)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupBuyAdd = GUICtrlCreateGroup("Buyer's Address", 24, 264, 673, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$labelbuyadd1 = GUICtrlCreateLabel("Address:", 32, 304, 49, 18)
$labelbuyadd2 = GUICtrlCreateLabel("City, State, Zip:", 32, 336, 81, 18)
$labelbuycounty = GUICtrlCreateLabel("County:", 32, 368, 41, 18)
$InputBuyerAdd1 = GUICtrlCreateInput("", 120, 304, 561, 22)
GUICtrlSetTip(-1, "123 Main Street")
$InputBuyerAdd2 = GUICtrlCreateInput("", 120, 336, 561, 22)
GUICtrlSetTip(-1, "City, State Zip")
$InputBuyerAdd3 = GUICtrlCreateInput("", 120, 368, 561, 22)
GUICtrlSetTip(-1, "County")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Seller = GUICtrlCreateTabItem("Seller")
$Group1 = GUICtrlCreateGroup("Seller 1", 26, 73, 329, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$InputSeller1 = GUICtrlCreateInput("", 122, 105, 217, 22)
GUICtrlSetTip(-1, "Sally the Seller, LLC")
$Labelseller1 = GUICtrlCreateLabel("Seller 1 Name:", 34, 105, 73, 18)
$SellerMarried = GUICtrlCreateRadio("Married", 34, 161, 65, 17)
$SellerSingle = GUICtrlCreateRadio("Single", 34, 137, 57, 17)
$SellerLLC = GUICtrlCreateRadio("LLC", 34, 185, 57, 17)
$SellerInc = GUICtrlCreateRadio("Inc.", 34, 209, 49, 17)
$Label2 = GUICtrlCreateLabel("State (only if LLC or Inc.):", 138, 209, 127, 18)
$InputSellerEntityState = GUICtrlCreateInput("", 274, 209, 73, 22)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Seller 2", 372, 73, 321, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label3 = GUICtrlCreateLabel("Seller 2 Name:", 380, 105, 73, 18)
$InputSeller2 = GUICtrlCreateInput("", 468, 105, 209, 22)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Seller's Address", 26, 265, 673, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label4 = GUICtrlCreateLabel("Address:", 34, 305, 49, 18)
$Label5 = GUICtrlCreateLabel("City, State Zip:", 34, 337, 81, 18)
$Label6 = GUICtrlCreateLabel("County:", 34, 369, 41, 18)
$InputSellerAdd1 = GUICtrlCreateInput("", 122, 305, 561, 22)
GUICtrlSetTip(-1, "123 Main Street")
$InputSellerAdd2 = GUICtrlCreateInput("", 122, 337, 561, 22)
GUICtrlSetTip(-1, "City, State Zip")
$InputSellerAdd3 = GUICtrlCreateInput("", 122, 369, 561, 22)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Lender = GUICtrlCreateTabItem("Lender")
GUICtrlSetState(-1,$GUI_SHOW)
$Group5 = GUICtrlCreateGroup("Lender Info", 19, 73, 393, 161)
$Label7 = GUICtrlCreateLabel("Address:", 27, 129, 45, 17)
$Label8 = GUICtrlCreateLabel("City, State, Zip:", 27, 161, 81, 18)
$Label9 = GUICtrlCreateLabel("County:", 27, 193, 40, 17)
$InputLenderAdd1 = GUICtrlCreateInput("", 115, 129, 281, 21)
GUICtrlSetTip(-1, "123 Main Street")
$InputLenderAdd2 = GUICtrlCreateInput("", 115, 161, 281, 21)
GUICtrlSetTip(-1, "City, State, Zip")
$InputLenderAdd3 = GUICtrlCreateInput("", 115, 193, 281, 21)
GUICtrlSetTip(-1, "e.g. Tarrant County")
$Label1 = GUICtrlCreateLabel("Lender Name:", 27, 97, 71, 17)
$InputLender = GUICtrlCreateInput("", 115, 97, 281, 21)
GUICtrlSetTip(-1, "We Lend Things, Inc.")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Loan Info:", 16, 248, 681, 201)
$Label10 = GUICtrlCreateLabel("Principal:", 27, 272, 47, 17)
$Label11 = GUICtrlCreateLabel("Write Out:", 27, 305, 52, 17)
$Label14 = GUICtrlCreateLabel("", 27, 337, 4, 4)
$InputPrincipal = GUICtrlCreateInput("", 88, 272, 153, 21)
GUICtrlSetTip(-1, "$xx,xxx.xx")
$InputWriteOut = GUICtrlCreateEdit("", 88, 304, 593, 129, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetTip(-1, "THIS MANY AND NO/100 DOLLARS (NO LINE BREAKS)")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group6 = GUICtrlCreateGroup("Trustee Info", 418, 73, 281, 161)
$Label18 = GUICtrlCreateLabel("Trustee Name:", 426, 97, 74, 17)
$InputTrustee = GUICtrlCreateInput("", 506, 97, 185, 21)
GUICtrlSetTip(-1, "I.M. Trustworthy, Jr.")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateTabItem("")
$GFLabel = GUICtrlCreateLabel("GF No:", 8, 8, 38, 17)
$CommonLabel = GUICtrlCreateLabel("Property Address:", 128, 8, 87, 17)
$CloseDateLabel = GUICtrlCreateLabel("Closing Date:", 544, 8, 67, 17)
$InputGF = GUICtrlCreateInput("", 48, 8, 73, 21)
GUICtrlSetTip(-1, "123456-RN-X")
$InputCommon = GUICtrlCreateInput("", 216, 8, 321, 21)
GUICtrlSetTip(-1, "Common address from front of file")
$InputInvoiceNo = GUICtrlCreateInput("", 72, 472, 129, 21)
$HelpButton = GUICtrlCreateButton("Help", 632, 32, 81, 25)
$LabelInvoiceNo = GUICtrlCreateLabel("Invoice No.", 8, 472, 59, 17)
$InputClosingDate = GUICtrlCreateInput("", 616, 8, 97, 21)
GUICtrlSetTip(-1, "Close date from contract")
$SaveButton = GUICtrlCreateButton("Save", 640, 472, 73, 25)
GUICtrlSetTip(-1, "Click this when you're ready to prep docs")
$InputType = GUICtrlCreateCombo("", 304, 472, 129, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "GWD|WDVL|WDMR|WDVLMR|SWD|SWDVL|SWDMR|SWDVLMR|Note & DoT|Wraparound Package")
$Label12 = GUICtrlCreateLabel("Doc Type:", 248, 472, 54, 17)
$Label13 = GUICtrlCreateLabel("Doc Cost:", 440, 472, 51, 17)
$InputCost = GUICtrlCreateInput("", 496, 472, 73, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $GF, $type, $fail[0][2], $addfail[1][2], $n = "", $invoice = 4, $sleep = 50, $aArray_invoice[12][2] = [["Field","Data"]], $buyerentitystate, $sellerentitystate, $buyerstatus, $sellerstatus, $buyer2, $seller2, $Cid, $arrayadd[1][2], $Fields[] = ["[Legal]","[Common]","[GF]","[CloseDate]","[Buyer 1]","[Buyer 2]","[Buyeradd1]","[Buyeradd2]","[Buyeradd3]","[Seller 1]","[Seller 2]","[Selleradd1]","[Selleradd2]","[Selleradd3]","[Lender]","[Lenderadd1]","[Lenderadd2]","[Lenderadd3]","[Principal]","[Write Out]","[Trustee]","[Invoice No.]","[Type]"]
hotkeyset("`", "prep")

While 1 ; What to do when buttons are pressed/forms are filled
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $HelpButton
            msgbox(-1, "Help", "Under construction!")
         Case $SaveButton
            Read()
            Parties()
            Buyers()
            Sellers()
            _arraydisplay($aArray_Base, "Saved Data")
    EndSwitch
 WEnd

 Func Read() ; Function for getting all data from input boxes
    global $aArray_Base[0][2] ; Start with clean array each time function is run
    For $n = 1 to 23 ; Make sure upper boundary is highest number in ctrl()!!
       If Guictrlread(Ctrl($n)) = NOT ("" OR 0)  Then ; Skip blank data
            $arrayadd[0][0] = $Fields[$n-1]         ; Define temporary array with data from $fields and Ctrl($n)
            $arrayadd[0][1] = Guictrlread(Ctrl($n)) ;
         If _arraysearch($aArray_Base, $arrayadd[0][0]) = NOT (-1) Then ; If [Field] is already in main array, replace data from input box, leave [Field] same
            $aArray_Base[_arraysearch($aArray_Base, $arrayadd[0][0])][1] = GuiCtrlRead(Ctrl($n))
         ElseIf @error = (6 OR 3) Then ; If Data not found or main array is empty, append new index to main array
         _arrayadd($aArray_Base, $arrayadd)
         EndIf
      EndIf
   Next
 EndFunc

 Func Ctrl($n) ; Function for passing control handles to for loops
    Select
    Case $n = 1
       $cid = $inputlegal
    Case $n = 2
       $cid = $inputcommon
    Case $n = 3
       $cid = $inputGF
    Case $n = 4
       $cid = $inputClosingDate
    Case $n = 5
       $cid = $inputBuyer1
    Case $n = 6
       $cid = $inputBuyer2
    Case $n = 7
       $cid = $inputBuyeradd1
    Case $n = 8
       $cid = $inputBuyeradd2
    Case $n = 9
       $cid = $inputBuyeradd3
    Case $n = 10
       $cid = $inputSeller1
    Case $n = 11
       $cid = $inputSeller2
    Case $n = 12
       $cid = $inputSelleradd1
    Case $n = 13
       $cid = $inputSelleradd2
    Case $n = 14
       $cid = $inputSelleradd3
    Case $n = 15
       $cid = $inputLender
    Case $n = 16
       $cid = $inputLenderadd1
    Case $n = 17
       $cid = $inputLenderadd2
    Case $n = 18
       $cid = $inputLenderadd3
    Case $n = 19
       $cid = $inputPrincipal
    Case $n = 20
       $cid = $inputWriteOut
    Case $n = 21
       $cid = $inputTrustee
    Case $n = 22
       $cid = $inputInvoiceNo
    Case $n = 23
       $cid = $inputType
    EndSelect
    Return $Cid
 EndFunc

Func Parties() ; Determine how many buyers and sellers
   local $row = _arraysearch($aArray_Base, "[Seller 2]")
  If  $row = -1 Then ; If no seller 2, seller 2 false
     global $2sellers = False
  ElseIf $aArray_Base[$row][1] = "" Then ; If seller 2 label, but not data, seller 2 false
     global $2sellers = False
  Else ; If seller 2 label and data, seller 2 true
     Global $2sellers = True
  EndIf
   local $row = _arraysearch($aArray_Base, "[Buyer 2]")
  If  $row = -1 Then
     global $2buyers = False
  ElseIf $aArray_Base[$row][1] = "" Then
     global $2buyers = False
  Else
     global $2buyers = True
  EndIf
  msgbox(-1, "", "2sellers " & $2sellers & "2buyers " & $2buyers)
EndFunc

Func Buyers()
If $2buyers = False Then ; [Buyer1&2] = [Buyer 1]
   local  $row = _arraysearch($aArray_Base, "[Buyer 1]")
   If $row = NOT -1 Then ; account for blank [Buyer 1]
   $arrayadd[0][0] = "[Buyer1&2]"
   $arrayadd[0][1] = $aArray_Base[$row][1]
   _arrayadd($aArray_Base, $arrayadd)

   $arrayadd[0][0] = "[Buyer 2]" ; Delete Buyer 2 if found
   $arrayadd[0][1] = ""
   _arrayadd($aArray_Base, $arrayadd)
   EndIf
ElseIf $2buyers = True Then ; [Buyer1&2] = [Buyer 1] and [Buyer 2]
   Local $1row = _arraysearch($aArray_Base, "[Buyer 1]")
   Local $2row = _arraysearch($aArray_Base, "[Buyer 2]")
    $arrayadd[0][0] = "[Buyer1&2]"
    $arrayadd[0][1] = "" & $aArray_Base[$1row][1] & " and " & $aArray_Base[$2row][1]
   _arrayadd($aArray_Base, $arrayadd)
EndIf
EndFunc

Func Sellers()
If $2sellers = False Then
   local $row = _arraysearch($aArray_Base, "[Seller 1]")
   msgbox(-1, "Sellers()","$row = " & $row)
   If $row = NOT -1 Then
      msgbox(-1, "Sellers()", "$row is not -1")
   $arrayadd[0][0] = "[Seller1&2]"
   msgbox(-1, "Sellers()", "$arrayadd[0][0] = " & $arrayadd[0][0])
   $arrayadd[0][1] = $aArray_Base[$row][1]
   msgbox(-1, "", "$arrayadd[0][1] = " & $arrayadd[0][1])
   _arrayadd($aArray_Base, $arrayadd)

   $arrayadd[0][0] = "[Seller 2]"
   $arrayadd[0][1] = ""
   _arrayadd($aArray_Base, $arrayadd)
   EndIf
ElseIf $2sellers = True Then
   Local $1row = _arraysearch($aArray_Base, "[Seller 1]")
   Local $2row = _arraysearch($aArray_Base, "[Seller 2]")
    $arrayadd[0][0] = "[Seller1&2]"
    $arrayadd[0][1] = "" & $aArray_Base[$1row][1] & " and " & $aArray_Base[$2row][1]
   _arrayadd($aArray_Base, $arrayadd)
   EndIf
EndFunc

Func Signatures() ; Create labels and data to fill buyer/seller fields with data entered already
EndFunc

Func Acknowledge() ; Format and fill acknowledgements based on number and type of buyers and sellers
EndFunc

Func prep()
  local $oWord = _Word_Create() ; Create Application Object
   If @error Then
      Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", "Error creating application object. Script terminated.")
   EndIf
  local $filepath = "C:\Users\Randy\Dropbox\Doc Prep\_KNDS Doc Prep Wizard (windows only)\GWD - Seller(s) People - Experiment.docx" ; Select Template to open
  local $oDoc = _word_docopen($oWord, $filepath) ; Open template
   If @error Then
      Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", "Error opening template. Script terminated.")
   EndIf
   For $i = 1 to Ubound($aArray_Base) ; Find and replace all [Fields] from main array with data
      _Word_DocFindReplace($oDoc, "" & $aArray_base[$i-1][0], "" & $aArray_Base[$i-1][1])
         If @error Then
            $addfail[0][0] = $aArray_Base[$i-1][0]
            $addfail[0][1] = $aArray_Base[$i-1][1]
            _arrayadd($fail, $addfail)
   EndIf
Next
   _ArrayDisplay($fail, "Items not replaced")
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", "Completed Find and replace. Iterations: "&$i)
   _word_docsaveas($oDoc, @HomeDrive & @HomePath & "\Dropbox\Doc Prep\_KNDS Doc Prep Wizard (windows only)\___Completed\" & guictrlread($inputgf) & " - " & guictrlread($inputtype)) ; Save working document with GF number
      If @error Then
      Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", "Error saving deed document. Script terminated." & @CRLF &  "Make sure Dropbox is installed on the PC." & @CRLF & @CRLF & "Also make sure that the following filepath exists:" & @CRLF & @CRLF & @HomeDrive & @HomePath & "\Dropbox\Doc Prep\_KNDS Doc Prep Wizard (windows only)\___Completed\")
   EndIf
   Shellexecute("" & @homedrive & @homepath & "\Dropbox\Doc Prep\_KNDS Doc Prep Wizard (windows only)\___Completed\")
   MsgBox($MB_SYSTEMMODAL, "KNDS Doc Prep Wizard", "Documents successfully prepared." & @CRLF & "Please inspect the document and the invoice for any errors, then drag and drop them to the appropriate location to save dropbox space.")
EndFunc

 

 

Share this post


Link to post
Share on other sites
anoig

Hi all,

I figured it out. Sorry for the inconvenience. I was doing this:

Func Buyers()
If $2buyers = False Then ; [Buyer1&2] = [Buyer 1]
   local  $row = _arraysearch($aArray_Base, "[Buyer 1]")
   If $row = NOT -1 Then ; account for blank [Buyer 1] ; <================= ERROR IS HERE
   $arrayadd[0][0] = "[Buyer1&2]"
   $arrayadd[0][1] = $aArray_Base[$row][1]
   _arrayadd($aArray_Base, $arrayadd)

   $arrayadd[0][0] = "[Buyer 2]" ; Delete Buyer 2 if found
   $arrayadd[0][1] = ""
   _arrayadd($aArray_Base, $arrayadd)
   EndIf
ElseIf $2buyers = True Then ; [Buyer1&2] = [Buyer 1] and [Buyer 2]
   Local $1row = _arraysearch($aArray_Base, "[Buyer 1]")
   Local $2row = _arraysearch($aArray_Base, "[Buyer 2]")
    $arrayadd[0][0] = "[Buyer1&2]"
    $arrayadd[0][1] = "" & $aArray_Base[$1row][1] & " and " & $aArray_Base[$2row][1]
   _arrayadd($aArray_Base, $arrayadd)
EndIf
EndFunc

Using $row = NOT -1 was causing problems, although I'm not sure why. Using $row <> -1 fixed everything. Thanks anyway!

-Anoig

Edited by anoig

Share this post


Link to post
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

  • Similar Content

    • Emmhor1
      By Emmhor1
      Hi All,

      MAIN QUESTION:
      Is it possible to Call specific function within a GUI

      So I have a script with multiple functions although I don't want to use every function every time.
      My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button.
      I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one.
      This script is on my work laptops and cannot access it right now.
       
      Who can help me with this?
      GUIcreate
      Func1 
      Func2
      Func3
      Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script)
      Then a button which executes/calls the selected functions
    • Skeletor
      By Skeletor
      Hi Virtual People,
      My array works perfectly fine. However, what is the best practice if the line in the array doesn't have the correct amount of columns and if I can add a placeholder?

       
      For $count = 1 To _FileCountLines($FileRead1) Step 1 $string = FileReadLine($FileRead1, $count) $input = StringSplit($string, ",", 1) $value1 = $input[1] $value2 = $input[2] $value3 = $input[3] _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value2, "A1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value1, "B1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value3, "C1") Next  
    • MrCheese
      By MrCheese
      hi all,
      reviewing the forum, this thread is applicable: 
       
       
      I wanted to know if there is now a better way to do this?
      In essence, I load a tab delimited txt file into an array (works well). I used tab, as some fields in the original csv contains commas.
      However, I needed autoit to manipulate this array, and output it as a csv.
      IF my array contains items with a comma, without double quotes around the field, then how best do I get a csv out of this?
      My current workaround is to filewritefromarray tab delimited, then open it in excel and save as a csv. I will need to check this to see how the address fields behave that contain a comma.
       
      Any thoughts would be appreciated.
       
    • Skeletor
      By Skeletor
      Hi All,

      I would like to know how you would take a FileLineRead and insert it into an array which then inserts it into Excel?
      One thing to know is the files content is broken up, so I only use half of the content within $FileRead1.
      So its imperative that the $value1, $value2, etc variables be used. 
      Code below:
      $FileRead1 = FileReadLine("C:\temp\sample.txt",1) For $count = 1 To _FileCountLines($FileRead1) Step 1 $string = FileReadLine($FileRead1, $count) $input = StringSplit($string, ",", 1) $value1 = $input[1] $value2 = $input[2] $value3 = $input[3] $value4 = $input[4] _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value1, "A1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value2, "B1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value3, "C1") _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $value4, "D1") Next  
    • AnonymousX
      By AnonymousX
      Hello,
      I'm trying to write a script that moves copies excel cells into an array. I'll than manipulate the values and send array into another program. 
      I don't want range to be specific to a workbook, or sheet, or set of cells.
      I want user to be able to highlight desired cells and to copy either normally ("Ctrl+C") or by a hotkey ("Alt+C"). 
      Could someone help me with this?
      Thank you,
      I've tried to write the framework: (edited)
      #include <MsgBoxConstants.au3> #include <Array.au3> #include <Excel.au3> HotKeySet("!v", "Pastedata") While True Sleep(1000) WEnd func Makearray() local $bArray ;User has cells already copied ;Convert clipboard into an array ;I don;t know how excel stores data to clipboard so don;t know how to bring it into array _Arraydisplay($bArray) MsgBox(0,0,$bArray) return $bArray endfunc func Pastedata() Local $aArray MsgBox(0,0,"wait",1) ;make array based on assumption user has already copied a range to clipboard $aArray = Makearray() ;paste code ;don;t worry about this I got the rest endfunc  
×