dopeness Posted July 10, 2016 Share Posted July 10, 2016 Right now I'm developing a program. I'm trying to write some data to a new column but it's just getting written into a new row. I've provided an image. The green section is ok, it's supposed to be in that column, but the red isn't. The red is supposed to be in the next column. https://s32.postimg.org/r65uu66zp/aaaaaaaaaaa.png The code I have is: $referencesArray[0] = "some text with new line breaks." $referencesArray[1] = "some more text with new line breaks." ;Isn't this supposed to write into a new column on each ref array?? Local $newarray[2][2] = [ [ $referencesArray[0] ],[ $referencesArray[1] ] ] Link to comment Share on other sites More sharing options...
water Posted July 10, 2016 Share Posted July 10, 2016 _Word_DocTableWrite only takes a "simple" array. No nested arrays. Try something like this If you want to let Word do the line breaks = start a new row. Local $aDocTable[1][2] = [["some text with new line breaks.", "some more text with new line breaks."]] Or split the text into an array and fill $aDocTable row by row. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
dopeness Posted July 10, 2016 Author Share Posted July 10, 2016 Thanks a lot for the response, I'll test it now and let you know if it works. Link to comment Share on other sites More sharing options...
dopeness Posted July 10, 2016 Author Share Posted July 10, 2016 (edited) Ok that didn't work. It put the referencesArray[1] first line on the next column, but its not at the top, more in the middle. The rest of referencesArray[1] was put back in the first column with the referencesArray[0] data. Any ideas? Edit 2: I tried filling the array with this code: $split1 = StringSplit($referencesArray[0], @CR) $split2 = StringSplit($referencesArray[1], @CR) Local $dataput[1][10] For $i = 1 To UBound($split1)-1 Step 1 If Not Mod($i,2) = 0 Then $dataput[0][$i] = $split1[$i] Else $dataput[0][$i] = $split2[$i] & @CR EndIf If $i = 6 Then ExitLoop EndIf Next _Word_DocTableWrite($f, $dataput, 0) But no luck. I know my logic is terribly wrong lol, can some one help? Edited July 10, 2016 by dopeness Link to comment Share on other sites More sharing options...
water Posted July 10, 2016 Share Posted July 10, 2016 Will try tomorrow as soon as I return to my office. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted July 11, 2016 Share Posted July 11, 2016 You need something like this: #include <Array.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <Word.au3> ; Create application object Local $oWord = _Word_Create() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableRead Example", _ "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Open the test document Local $oDoc = _Word_DocAdd($oWord) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableRead Example", _ "Error opening new document." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Create a table from an array Local $sIn1 = "NL1" & @CRLF & "NL2" Local $sIN2 = "b1" & @CRLF & "b2" & @CRLF & "b3" Local $aTemp1 = StringSplit($sIn1, @CRLF, $STR_ENTIRESPLIT) Local $aTemp2 = StringSplit($sIn2, @CRLF, $STR_ENTIRESPLIT) Local $iRows = ($aTemp1[0] > $aTemp2[0]) ? $aTemp1[0] : $aTemp2[0] Local $aOut[$iRows][2] For $i = 1 To $aTemp1[0] $aOut[$i - 1][0] = $aTemp1[$i] Next For $i = 1 To $aTemp2[0] $aOut[$i - 1][1] = $aTemp2[$i] Next Local $oRange = _Word_DocRangeSet($oDoc, -2) Local $oTable = _Word_DocTableWrite($oRange, $aOut, 0) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableRead Example", _ "Error creating the table." & @CRLF & "@error = " & @error & ", @extended = " & @extended) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
dopeness Posted July 11, 2016 Author Share Posted July 11, 2016 Hmm that actually looks like it can work! Thanks a lot man, I'll test it out and let you know how it goes. Also, Autoit supports ternary operators?! Themoreyouknow.jpg Link to comment Share on other sites More sharing options...
water Posted July 11, 2016 Share Posted July 11, 2016 Yes. Ternary operators have been implemented with AutoIt 3.3.10.0 (according to the help file): Quote Added: C++ style ternary operators: Local $fResult = ("foo" = "bar") ? True : False. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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