viptnn Posted January 3, 2016 Share Posted January 3, 2016 anyone know how to edit available table at word: add row or fill data to cell. I have searched but not found Link to comment Share on other sites More sharing options...
water Posted January 3, 2016 Share Posted January 3, 2016 It depends ...You could use the Word UDF that comes with AutoIt. Use function _Word_DocTableRead to retrieve the current table, then modify the array and rewrite the table using function _Word_DocTableWrite.As the functions only retrieve the text, formatting will be lost.Another possible way is to use MS COM interface to Word. But this will take a bit more time and effort. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
kcvinu Posted January 3, 2016 Share Posted January 3, 2016 It's easy with MS COM. read this for writing texthttps://msdn.microsoft.com/en-us/library/tkf9d64e.aspxAnd this for adding rows and colshttps://msdn.microsoft.com/en-us/library/2dw39e8e.aspx viptnn 1 Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
water Posted January 3, 2016 Share Posted January 3, 2016 If you have problems translating the code to AutoIt please post your questions here. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
viptnn Posted January 4, 2016 Author Share Posted January 4, 2016 If you have problems translating the code to AutoIt please post your questions here.Autoit is the first language i study, so please teach me how to translate VBA to autoit.Me.Application.ActiveDocument.Tables.Item(1).Rows.Add()With Me.Tables.Item(1).Cell(1, 1).Range .Text = "Name" .ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight End With Link to comment Share on other sites More sharing options...
kcvinu Posted January 4, 2016 Share Posted January 4, 2016 @viptnn ,First of all, you need to create or get the word's com object. Use "ObjCreate" or "ObjGet" function for that. Read the help file for more details.Remember, When using ObjCreate, you are going to create a new instance of word and when using ObjGet, your trying to connect the already opened word instance. And when you create or get the object, then you can use it like this for the above given code.For example, this is the vb code Me.Application.ActiveDocument.Tables.Item(1).Rows.Add()You can write it like thisLocal $oWord = ObjGet("","Word.Application") $oWord.ActiveDocument.Tables.Item(1).Rows.Add()So simple. And do not forget to check the constants for WordConstants.au3 in include folder. viptnn 1 Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
water Posted January 4, 2016 Share Posted January 4, 2016 To create the Word COM object and to open the document you can use _Word_Create, _Word_DocOpen from the Word UDF that comes with AutoIt.The UDF makes things a bit easier and comes with error checking already included. kcvinu and viptnn 2 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
viptnn Posted January 4, 2016 Author Share Posted January 4, 2016 For example, this is the vb code Me.Application.ActiveDocument.Tables.Item(1).Rows.Add()You can write it like thisLocal $oWord = ObjGet("","Word.Application") $oWord.ActiveDocument.Tables.Item(1).Rows.Add()So simple. And do not forget to check the constants for WordConstants.au3 in include folder.Its look like very easy, i can do with second case. Thank you so much Dim $oDoc = $oWord.ActiveDocument With $oDoc.Tables.Item(1).Cell(1, 1).Range .Text = "Name" .ParagraphFormat.Alignment = "Word.WdParagraphAlignment.wdAlignParagraphRight" EndWith Link to comment Share on other sites More sharing options...
water Posted January 4, 2016 Share Posted January 4, 2016 Autoit does not support the VB way to use application related constants. Try:; Enumeration taken from: https://msdn.microsoft.com/en-us/library/ff835817%28v=office.14%29.aspx Global $wdAlignParagraphRight = 2 ; Right-aligned Global $oDoc = $oWord.ActiveDocument With $oDoc.Tables.Item(1).Cell(1, 1).Range .Text = "Name" .ParagraphFormat.Alignment = $wdAlignParagraphRight EndWith My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
kcvinu Posted January 4, 2016 Share Posted January 4, 2016 @water, I think these constants are already declared in WordConstants.au3. So inclusing that file is the right way, is it ? Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
water Posted January 4, 2016 Share Posted January 4, 2016 The Word UDF only has those constants defined in WordConstants.au3 which are used as parameters by one of the functions of the Word UDF.Else WordConstants.au3 would have become way too big. kcvinu 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - 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