FrancescoDiMuro Posted February 16, 2017 Share Posted February 16, 2017 Good morning everyone I was talking about this UDF in this thread, but for not confusing "arguments", I opened a new thread... So, the issue I'm having, is the format of the table, that you can see in the image above... Can you help me out please? Thanks Text of the previous post: Quote Talking about Word UDF, I have a 2D array ( returned by a ListView ), and I would like to create a report with this array, inside a Word table... I tried with this, but texts are a bit untidy... Can you help me out, please? Local $oWord = _Word_Create(False) If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la creazione dell'oggetto Word." & @CRLF & "Errore: " & @error) Else ; The field alreay exists, but would be nice if I can create it... I thought at _FileCreate() :) Local $oDoc = _Word_DocOpen($oWord, $sCartellaModelli & "\Esportazione_Modello.doc") If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'aggiunta di un nuovo documento Word." & "Errore: " & @error) Else Local $oRange = _Word_DocRangeSet($oWord, 0) If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante il settaggio del range nel documento Word." & @CRLF & "Errore: " & @error) Else _Word_DocTableWrite($oRange, $aListView, Default) If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la creazione della tabella." & @CRLF & "Errore: " & @error & "Informazioni: " & @extended) Else _Word_DocSaveAs($oDoc, $sCartellaEsportazioni & "\Esportazione_di_prova.doc") EndIf EndIf EndIf EndIf And this is the actual result: Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted February 20, 2017 Author Share Posted February 20, 2017 SUPER BUMP! Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
water Posted February 20, 2017 Share Posted February 20, 2017 Can you please post an example how the report should look like? 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...
water Posted February 20, 2017 Share Posted February 20, 2017 (edited) BTW: To make your code a bit more readable I suggest following changes: Local $oWord = _Word_Create(False) If @error Then Exit MsgBox($MB_ICONERROR, "Errore!", "Errore durante la creazione dell'oggetto Word." & @CRLF & "Errore: " & @error) ; The field alreay exists, but would be nice if I can create it... I thought at _FileCreate() :) Local $oDoc = _Word_DocOpen($oWord, $sCartellaModelli & "\Esportazione_Modello.doc") If @error Then Exit MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'aggiunta di un nuovo documento Word." & "Errore: " & @error) Local $oRange = _Word_DocRangeSet($oWord, 0) If @error Then Exit MsgBox($MB_ICONERROR, "Errore!", "Errore durante il settaggio del range nel documento Word." & @CRLF & "Errore: " & @error) _Word_DocTableWrite($oRange, $aListView, Default) If @error Then Exit MsgBox($MB_ICONERROR, "Errore!", "Errore durante la creazione della tabella." & @CRLF & "Errore: " & @error & "Informazioni: " & @extended) _Word_DocSaveAs($oDoc, $sCartellaEsportazioni & "\Esportazione_di_prova.doc") If @error Then Exit MsgBox($MB_ICONERROR, "Errore!", "..." & @CRLF & "Errore: " & @error & "Informazioni: " & @extended) Edited February 20, 2017 by water 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...
FrancescoDiMuro Posted February 20, 2017 Author Share Posted February 20, 2017 @water Good morning The report should look like a table containing a header, with names of columns of the data the report is representing... Header 1|Header 2 Data 1.1 | Data 2.1 Data 1.2 | Data 2.2 So on... I have 15 columns ( SQLite table ), and some descriptions are quite long... 3 minutes ago, water said: BTW: To make your code a bit more readable I suggest following changes: Thanks for the suggestion Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
water Posted February 20, 2017 Share Posted February 20, 2017 So the data in the screenshot you posted above is correct but the formatting needs some brush up? 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...
FrancescoDiMuro Posted February 20, 2017 Author Share Posted February 20, 2017 Absolutely yes @water! O.T.: I don't know why sometimes tags on users doesn't work... :/ Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
water Posted February 20, 2017 Share Posted February 20, 2017 (edited) Function _Word_DocTableWrite returns the table object. The format of this object needs to be modified. Details can be found here: https://msdn.microsoft.com/en-us/library/ff195902(v=office.14).aspx Example: Local $oTable = _Word_DocTableWrite($oRange, $aListView, Default) $oTable.Columns.SetWidth(100) ; Sets the width of all columns to 50 points BTW: 1 Centimeter = 28.3464567 Points 1 Point = 0.0352777778 Centimeters Edited February 20, 2017 by water 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...
FrancescoDiMuro Posted February 20, 2017 Author Share Posted February 20, 2017 (edited) @water Just a little question... Is the procedure you wrote above to create a blank report, which in insert a table, correct? The range and other stuffs? It's the first time I'm using, so I want to do it in the right way Thanks for your help! Edited February 20, 2017 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
water Posted February 20, 2017 Share Posted February 20, 2017 As you want to create a completely new report I would change _Word_DocOpen to _Word_DocAdd: Local $oWord = _Word_Create(False) If @error Then Exit MsgBox($MB_ICONERROR, "Errore!", "Errore durante la creazione dell'oggetto Word." & @CRLF & "Errore: " & @error) ; Create a new empty document Local $oDoc = _Word_DocAdd($oWord) If @error Then Exit MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'aggiunta di un nuovo documento Word." & "Errore: " & @error) Local $oRange = _Word_DocRangeSet($oWord, 0) If @error Then Exit MsgBox($MB_ICONERROR, "Errore!", "Errore durante il settaggio del range nel documento Word." & @CRLF & "Errore: " & @error) _Word_DocTableWrite($oRange, $aListView, Default) If @error Then Exit MsgBox($MB_ICONERROR, "Errore!", "Errore durante la creazione della tabella." & @CRLF & "Errore: " & @error & "Informazioni: " & @extended) _Word_DocSaveAs($oDoc, $sCartellaEsportazioni & "\Esportazione_di_prova.doc") If @error Then Exit MsgBox($MB_ICONERROR, "Errore!", "..." & @CRLF & "Errore: " & @error & "Informazioni: " & @extended) 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...
FrancescoDiMuro Posted February 20, 2017 Author Share Posted February 20, 2017 Hey @water! Thank you for your help I'll update you as soon as possible ( as I develop this thing in my software )! Again, a big thanks! Have a good day Francesco Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette 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