Re: [libreoffice-users] gettextfields
On 9/05/2013 9:13, Vieri wrote: --- On Thu, 5/9/13, mcmurchy1917-libreoff...@yahoo.co.uk mcmurchy1917-libreoff...@yahoo.co.uk wrote: Hi Vieri The form you've created contains a set of controls of which one or more of them are of the Text box variety. You may also have other controls on the form such as a Check Box, Label or Push Button these latter controls don't have the ability to hold text or edit text so don't have the .Text property. So for these controls the code x.Text will fail. Try this Sub EnumerateFields oDoc = ThisComponent oDrawPage = oDoc.DrawPage oForm = oDrawPage.Forms.GetByIndex(0) For i = 0 To oForm.getCount()-1 x = oForm.getByIndex(i) if x.supportsService(com.sun.star.form.component.TextField) then Print x.getName() : x.Text End If Next End Sub Thanks Iain. Your help is much appreciated. The macro works. Now I'm trying to send HTTPS POST requests to my web server (not succeeding but that's another story). i use a create a Windows object to do the posting WinHttp.WinHttpRequest.5.1 hope it helps greetz Fernand Function MicrosoftTranslate(sLanguageFrom As String, sLanguageTo As String, sText As String) As String ' On Error Goto err_catch0 Dim ID As String Dim sURL As String Dim oH As object Dim sToken As String ID = sURL = http://api.microsofttranslator.com/V2/Ajax.svc/Translate?oncomplete=appId=; ID from= sLanguageFrom to= sLanguageTo text= JSencodeURLpart(sText) sToken = GetAccessToken() oH = CreateObject(WinHttp.WinHttpRequest.5.1) oH.Open POST, sURL, False oH.setRequestHeader Authorization, Bearer sToken oH.send t = oH.ResponseText MicrosoftTranslate = mid(t,3,len(t)-3) Set oH = Nothing exit_sub: Exit Function err_catch0: msgbox(err_catch0 Err Error Erl,48) Resume exit_sub End Function Function GetAccessToken() As String On Error Goto err_catch2 Dim mtToken As String webRequest = CreateObject(WinHttp.WinHttpRequest.5.1) Dim URI As String Dim txtToken As String URI = https://datamarket.accesscontrol.windows.net/v2/OAuth2-13; 'Client ID from https://datamarket.azure.com/developer/applications Dim clientId As String clientId = myclientid 'Client secret from https://datamarket.azure.com/developer/applications Dim clientSecret As String clientSecret = JTEGDEb1OViegnPz0kzkvRWhOSeNRJpmPgjqauyeV8k= Dim sRequest As String sRequest = grant_type=client_credentials _ client_id= JSencodeURLpart(clientId, false) _ client_secret= JSencodeURLpart(clientSecret, False) _ scope=http://api.microsofttranslator.com; webRequest.Open(POST,URI, False) webRequest.setRequestHeader Content-Type, application/x-www-form-urlencoded webRequest.send (srequest) mttoken = WebRequest.ResponseText Dim arr As Variant, header As String header = access_token: 'HMACSHA256= footer = ,expires_in: headerpos = instr(mttoken, header)+len(header) footerpos = instr(mttoken, footer) tokenl = footerpos-headerpos txtToken = mid(mttoken ,headerpos , tokenl) 'xray txttoken 'If txtToken = _request Then Resume err_catch: GetAccessToken = txtToken exit_sub: Exit Function err_catch2: beep msgbox(err_catch2 Err Error Erl, 48) Resume exit_sub End Function Function URLEncode(StringToEncode As String, UsePlusRatherThanHexForSpace As Boolean ) As String On Error Goto err_catch3 Dim TempAns As String Dim CurChr As Integer CurChr = 1 Do Until CurChr - 1 = Len(StringToEncode) Select Case Asc(Mid(StringToEncode, CurChr, 1)) Case 48 To 57, 65 To 90, 97 To 122 TempAns = TempAns Mid(StringToEncode, CurChr, 1) Case 32 If UsePlusRatherThanHexForSpace = True Then TempAns = TempAns + Else TempAns = TempAns % Hex(32) End If Case Else TempAns = TempAns % _ Right(0 Hex(Asc(Mid(StringToEncode, _ CurChr, 1))), 2) End Select CurChr = CurChr + 1 Loop URLEncode = TempAns exit_sub: Exit Function err_catch3: beep msgbox(err_catch3 Err Error Erl ,48) Resume exit_sub End Function Thanks again! Vieri -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette List archive: http://listarchives.libreoffice.org/global/users/ All messages sent to this list will be publicly archived and cannot be deleted
Re: [libreoffice-users] gettextfields
Thanks Fernand. I'm currently using Java (HttpURLConnection) to do the HTTP stuff (easier). For things that are simpler to do with Basic, I run other macros from within my Java macro (with XScript). Thanks for your suggestion. Vieri --- On Fri, 5/10/13, Fernand Vanrie s...@pmgroup.be wrote: From: Fernand Vanrie s...@pmgroup.be Subject: Re: [libreoffice-users] gettextfields To: users@global.libreoffice.org Date: Friday, May 10, 2013, 4:48 AM On 9/05/2013 9:13, Vieri wrote: --- On Thu, 5/9/13, mcmurchy1917-libreoff...@yahoo.co.uk mcmurchy1917-libreoff...@yahoo.co.uk wrote: Hi Vieri The form you've created contains a set of controls of which one or more of them are of the Text box variety. You may also have other controls on the form such as a Check Box, Label or Push Button these latter controls don't have the ability to hold text or edit text so don't have the .Text property. So for these controls the code x.Text will fail. Try this Sub EnumerateFields oDoc = ThisComponent oDrawPage = oDoc.DrawPage oForm = oDrawPage.Forms.GetByIndex(0) For i = 0 To oForm.getCount()-1 x = oForm.getByIndex(i) if x.supportsService(com.sun.star.form.component.TextField) then Print x.getName() : x.Text End If Next End Sub Thanks Iain. Your help is much appreciated. The macro works. Now I'm trying to send HTTPS POST requests to my web server (not succeeding but that's another story). i use a create a Windows object to do the posting WinHttp.WinHttpRequest.5.1 hope it helps greetz Fernand Function MicrosoftTranslate(sLanguageFrom As String, sLanguageTo As String, sText As String) As String ' On Error Goto err_catch0 Dim ID As String Dim sURL As String Dim oH As object Dim sToken As String ID = sURL = http://api.microsofttranslator.com/V2/Ajax.svc/Translate?oncomplete=appId=; ID from= sLanguageFrom to= sLanguageTo text= JSencodeURLpart(sText) sToken = GetAccessToken() oH = CreateObject(WinHttp.WinHttpRequest.5.1) oH.Open POST, sURL, False oH.setRequestHeader Authorization, Bearer sToken oH.send t = oH.ResponseText MicrosoftTranslate = mid(t,3,len(t)-3) Set oH = Nothing exit_sub: Exit Function err_catch0: msgbox(err_catch0 Err Error Erl,48) Resume exit_sub End Function Function GetAccessToken() As String On Error Goto err_catch2 Dim mtToken As String webRequest = CreateObject(WinHttp.WinHttpRequest.5.1) Dim URI As String Dim txtToken As String URI = https://datamarket.accesscontrol.windows.net/v2/OAuth2-13; 'Client ID from https://datamarket.azure.com/developer/applications Dim clientId As String clientId = myclientid 'Client secret from https://datamarket.azure.com/developer/applications Dim clientSecret As String clientSecret = JTEGDEb1OViegnPz0kzkvRWhOSeNRJpmPgjqauyeV8k= Dim sRequest As String sRequest = grant_type=client_credentials _ client_id= JSencodeURLpart(clientId, false) _ client_secret= JSencodeURLpart(clientSecret, False) _ scope=http://api.microsofttranslator.com; webRequest.Open(POST,URI, False) webRequest.setRequestHeader Content-Type, application/x-www-form-urlencoded webRequest.send (srequest) mttoken = WebRequest.ResponseText Dim arr As Variant, header As String header = access_token: 'HMACSHA256= footer = ,expires_in: headerpos = instr(mttoken, header)+len(header) footerpos = instr(mttoken, footer) tokenl = footerpos-headerpos txtToken = mid(mttoken ,headerpos , tokenl) ' xray txttoken ' If txtToken = _request Then Resume err_catch: GetAccessToken = txtToken exit_sub: Exit Function err_catch2: beep msgbox(err_catch2 Err Error Erl, 48) Resume exit_sub End Function Function URLEncode(StringToEncode As String, UsePlusRatherThanHexForSpace As Boolean ) As String On Error Goto err_catch3 Dim TempAns As String Dim CurChr As Integer CurChr = 1 Do Until CurChr - 1 = Len(StringToEncode) Select Case Asc(Mid(StringToEncode, CurChr, 1)) Case 48 To 57, 65 To 90, 97 To 122 TempAns = TempAns Mid(StringToEncode, CurChr, 1) Case 32 If UsePlusRatherThanHexForSpace = True Then TempAns = TempAns + Else TempAns = TempAns % Hex(32) End If Case Else TempAns = TempAns % _ Right(0 Hex(Asc(Mid(StringToEncode, _ CurChr, 1))), 2) End Select CurChr = CurChr + 1 Loop URLEncode = TempAns exit_sub: Exit Function err_catch3: beep msgbox
Re: [libreoffice-users] gettextfields
Hi Vieri The form you've created contains a set of controls of which one or more of them are of the Text box variety. You may also have other controls on the form such as a Check Box, Label or Push Button these latter controls don't have the ability to hold text or edit text so don't have the .Text property. So for these controls the code x.Text will fail. Try this Sub EnumerateFields oDoc = ThisComponent oDrawPage = oDoc.DrawPage oForm = oDrawPage.Forms.GetByIndex(0) For i = 0 To oForm.getCount()-1 x = oForm.getByIndex(i) if x.supportsService(com.sun.star.form.component.TextField) then Print x.getName() : x.Text End If Next End Sub Iain On Wednesday 08 May 2013 04:16:52 Vieri wrote: Thanks! Making progress... finally. Your code actually retrieved the text within my first text box (which is at least something!) but then it fails with the error: LibreOffice 4.0.2.2 BASIC runtime error. '423' Text it points to line: Print x.getName() : x.Text It may be choking on a formatted field within the document. Just out of curiosity, how did you know that you had to use ThisComponent.DrawPage.Forms? As a novice, I find the documentation to be quite confusing and a supposedly simple task such as getting text field values seems to be quite difficult. I mean, I found examples on the net and they all start with something like: vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then Do While vEnum.hasMoreElements() vVal = vEnum.nextElement() but then I either don't know how to continue or the examples I found on the net don't work (maybe outdated OO or LO versions). BTW, is there an IDE that can auto-complete Basic code (eg. vVal.??? as in the example above). Thanks, Vieri --- On Wed, 5/8/13, mcmurchy1917-libreoff...@yahoo.co.uk mcmurchy1917- libreoff...@yahoo.co.uk wrote: I've created two Text Boxes in a form in a writer document. I can iterate over them like this grabbing the text as I go Sub EnumerateFields oDoc = ThisComponent oDrawPage = oDoc.DrawPage oForm = oDrawPage.Forms.GetByIndex(0) For i = 0 To oForm.getCount()-1 x = oForm.getByIndex(i) Print x.getName() : x.Text Next End Sub Does this help in anyway? Iain On Wednesday 08 May 2013 01:50:02 Vieri wrote: --- On Tue, 5/7/13, Vieri rentor...@yahoo.com wrote: --- On Mon, 5/6/13, Andrew Douglas Pitonyak and...@pitonyak.org wrote: On 05/06/2013 05:21 AM, Vieri wrote: Hi, I have an odt writer document with 2 input text fields (added with the form designer toolbar). I manually type text into one of the fields. I copy/pasted a macro to see if I could grab the text within the input field but haven't had any luck. This is the test macro in Basic: Sub EnumerateFields vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then If vEnum.hasMoreElements() Then Print OK Else Print NOT OK End If End If End Sub If I manually run this macro I get the NOT OK message. What am I doing wrong? What is the correct way of getting the text field elements? Thanks Vieri I grabbed these two routines from my test modules without running them first Hi, Thanks for the reply but I'm still having trouble. I'm either way off-course, misusing LO or making a dumb rookie mistake. I copied your macros to my odt document. I then did a tools, macros, run macro... and selected the Subs I copied. If I run EnumerateTextFields then it yields the Finished message box (nothing else). If I run DisplayMasterFields then it yields the following message: ===Text Field Masters=== (com.sun.star.text.fieldmaster.SetExpression.Illustration,Illustration) (com.sun.star.text.fieldmaster.SetExpression.Table,Table) (com.sun.star.text.fieldmaster.SetExpression.Text,Text) (com.sun.star.text.fieldmaster.SetExpression.Drawing,Drawing) My odt document has 2 input fields in a form. By the way, if I place a button within my form and configure the Mouse button pressed to launch, say, EnumerateTextFields then I get the following error message: LibreOffice 4.0.2.2 BASIC runtime error. '423' getTextFields and it points at the line: oEnum = oDoc.getTextFields().createEnumeration() I'm stuck on something that should
Re: [libreoffice-users] gettextfields
--- On Thu, 5/9/13, mcmurchy1917-libreoff...@yahoo.co.uk mcmurchy1917-libreoff...@yahoo.co.uk wrote: Hi Vieri The form you've created contains a set of controls of which one or more of them are of the Text box variety. You may also have other controls on the form such as a Check Box, Label or Push Button these latter controls don't have the ability to hold text or edit text so don't have the .Text property. So for these controls the code x.Text will fail. Try this Sub EnumerateFields oDoc = ThisComponent oDrawPage = oDoc.DrawPage oForm = oDrawPage.Forms.GetByIndex(0) For i = 0 To oForm.getCount()-1 x = oForm.getByIndex(i) if x.supportsService(com.sun.star.form.component.TextField) then Print x.getName() : x.Text End If Next End Sub Thanks Iain. Your help is much appreciated. The macro works. Now I'm trying to send HTTPS POST requests to my web server (not succeeding but that's another story). Thanks again! Vieri -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette List archive: http://listarchives.libreoffice.org/global/users/ All messages sent to this list will be publicly archived and cannot be deleted
Re: [libreoffice-users] gettextfields
2013/5/8 Vieri rentor...@yahoo.com: --- On Tue, 5/7/13, Vieri rentor...@yahoo.com wrote: --- On Mon, 5/6/13, Andrew Douglas Pitonyak and...@pitonyak.org wrote: On 05/06/2013 05:21 AM, Vieri wrote: Hi, I have an odt writer document with 2 input text fields (added with the form designer toolbar). I manually type text into one of the fields. I copy/pasted a macro to see if I could grab the text within the input field but haven't had any luck. This is the test macro in Basic: Sub EnumerateFields vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then If vEnum.hasMoreElements() Then Print OK Else Print NOT OK End If End If End Sub If I manually run this macro I get the NOT OK message. What am I doing wrong? What is the correct way of getting the text field elements? Thanks Vieri I grabbed these two routines from my test modules without running them first Hi, Thanks for the reply but I'm still having trouble. I'm either way off-course, misusing LO or making a dumb rookie mistake. I copied your macros to my odt document. I then did a tools, macros, run macro... and selected the Subs I copied. If I run EnumerateTextFields then it yields the Finished message box (nothing else). If I run DisplayMasterFields then it yields the following message: ===Text Field Masters=== (com.sun.star.text.fieldmaster.SetExpression.Illustration,Illustration) (com.sun.star.text.fieldmaster.SetExpression.Table,Table) (com.sun.star.text.fieldmaster.SetExpression.Text,Text) (com.sun.star.text.fieldmaster.SetExpression.Drawing,Drawing) My odt document has 2 input fields in a form. By the way, if I place a button within my form and configure the Mouse button pressed to launch, say, EnumerateTextFields then I get the following error message: LibreOffice 4.0.2.2 BASIC runtime error. '423' getTextFields and it points at the line: oEnum = oDoc.getTextFields().createEnumeration() I'm stuck on something that should be quite simple. I'm attaching my odt file hoping that someone can tell me what novice mistake I'm making. Trying to attach the file again but it seems that the mailing list strips it out. Thanks, Vieri -- Yes, that's the default behaviour for most mailing lists, I think. Not that it matters anymore, since you seem to have your problem solved, but next time you could upload the file somewhere and just give us the link here. Johnny Rosenberg -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette List archive: http://listarchives.libreoffice.org/global/users/ All messages sent to this list will be publicly archived and cannot be deleted
Re: [libreoffice-users] gettextfields
The problem is probably because these are input fields in a form. Either that, or it is because the fields are not anchored directly into the text in a way that enumerating text will display them. Can you email a copy of your document directly to me (off list). As long as it contains the text fields, that is sufficient (in other words, you can remove all the text that you like). On 05/07/2013 03:12 AM, Vieri wrote: --- On Mon, 5/6/13, Andrew Douglas Pitonyak and...@pitonyak.org wrote: On 05/06/2013 05:21 AM, Vieri wrote: Hi, I have an odt writer document with 2 input text fields (added with the form designer toolbar). I manually type text into one of the fields. I copy/pasted a macro to see if I could grab the text within the input field but haven't had any luck. This is the test macro in Basic: Sub EnumerateFields vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then If vEnum.hasMoreElements() Then Print OK Else Print NOT OK End If End If End Sub If I manually run this macro I get the NOT OK message. What am I doing wrong? What is the correct way of getting the text field elements? Thanks Vieri I grabbed these two routines from my test modules without running them first Hi, Thanks for the reply but I'm still having trouble. I'm either way off-course, misusing LO or making a dumb rookie mistake. I copied your macros to my odt document. I then did a tools, macros, run macro... and selected the Subs I copied. If I run EnumerateTextFields then it yields the Finished message box (nothing else). If I run DisplayMasterFields then it yields the following message: ===Text Field Masters=== (com.sun.star.text.fieldmaster.SetExpression.Illustration,Illustration) (com.sun.star.text.fieldmaster.SetExpression.Table,Table) (com.sun.star.text.fieldmaster.SetExpression.Text,Text) (com.sun.star.text.fieldmaster.SetExpression.Drawing,Drawing) My odt document has 2 input fields in a form. By the way, if I place a button within my form and configure the Mouse button pressed to launch, say, EnumerateTextFields then I get the following error message: LibreOffice 4.0.2.2 BASIC runtime error. '423' getTextFields and it points at the line: oEnum = oDoc.getTextFields().createEnumeration() I'm stuck on something that should be quite simple. I'm attaching my odt file hoping that someone can tell me what novice mistake I'm making. Thanks, Vieri -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette List archive: http://listarchives.libreoffice.org/global/users/ All messages sent to this list will be publicly archived and cannot be deleted
Re: [libreoffice-users] gettextfields
http://www.pitonyak.org/OOME_3_0.odt http://www.pitonyak.org/AndrewMacro.odt This document contains information on forms and such http://www.pitonyak.org/database/AndrewBase.odt On 05/08/2013 08:33 AM, Tom Davies wrote: Hi :) You might find it well worth buying the 3rd party guide produced by Andrew Pitonyak. This link helps get you there https://wiki.documentfoundation.org/Documentation/Other_Documentation_and_Resources#Programmers Andrew works hard on this list and in the Docs Team to help people with bitsbobs of code as do other people on this list but the book brings it all together rather well. It might be a good investment. I'm not sure how badly it is affected by alleged changes in the newer version of LO Basic being used by 4.0.0 and beyond but i suspect the book gives such a good overview that changes in the details are easy to figure out. Regards from Tom ) From: Vieri rentor...@yahoo.com To: users@global.libreoffice.org; mcmurchy1917-libreoff...@yahoo.co.uk Sent: Wednesday, 8 May 2013, 12:16 Subject: Re: [libreoffice-users] gettextfields Thanks! Making progress... finally. Your code actually retrieved the text within my first text box (which is at least something!) but then it fails with the error: LibreOffice 4.0.2.2 BASIC runtime error. '423' Text it points to line: Print x.getName() : x.Text It may be choking on a formatted field within the document. Just out of curiosity, how did you know that you had to use ThisComponent.DrawPage.Forms? As a novice, I find the documentation to be quite confusing and a supposedly simple task such as getting text field values seems to be quite difficult. I mean, I found examples on the net and they all start with something like: vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then Do While vEnum.hasMoreElements() vVal = vEnum.nextElement() but then I either don't know how to continue or the examples I found on the net don't work (maybe outdated OO or LO versions). BTW, is there an IDE that can auto-complete Basic code (eg. vVal.??? as in the example above). Thanks, Vieri --- On Wed, 5/8/13, mcmurchy1917-libreoff...@yahoo.co.uk mcmurchy1917-libreoff...@yahoo.co.uk wrote: I've created two Text Boxes in a form in a writer document. I can iterate over them like this grabbing the text as I go Sub EnumerateFields oDoc = ThisComponent oDrawPage = oDoc.DrawPage oForm = oDrawPage.Forms.GetByIndex(0) For i = 0 To oForm.getCount()-1 x = oForm.getByIndex(i) Print x.getName() : x.Text Next End Sub Does this help in anyway? Iain On Wednesday 08 May 2013 01:50:02 Vieri wrote: --- On Tue, 5/7/13, Vieri rentor...@yahoo.com wrote: --- On Mon, 5/6/13, Andrew Douglas Pitonyak and...@pitonyak.org wrote: On 05/06/2013 05:21 AM, Vieri wrote: Hi, I have an odt writer document with 2 input text fields (added with the form designer toolbar). I manually type text into one of the fields. I copy/pasted a macro to see if I could grab the text within the input field but haven't had any luck. This is the test macro in Basic: Sub EnumerateFields vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then If vEnum.hasMoreElements() Then Print OK Else Print NOT OK End If End If End Sub If I manually run this macro I get the NOT OK message. What am I doing wrong? What is the correct way of getting the text field elements? Thanks Vieri I grabbed these two routines from my test modules without running them first Hi, Thanks for the reply but I'm still having trouble. I'm either way off-course, misusing LO or making a dumb rookie mistake. I copied your macros to my odt document. I then did a tools, macros, run macro... and selected the Subs I copied. If I run EnumerateTextFields then it yields the Finished message box (nothing else). If I run DisplayMasterFields then it yields the following message: ===Text Field Masters=== (com.sun.star.text.fieldmaster.SetExpression.Illustration,Illustration) (com.sun.star.text.fieldmaster.SetExpression.Table,Table) (com.sun.star.text.fieldmaster.SetExpression.Text,Text) (com.sun.star.text.fieldmaster.SetExpression.Drawing,Drawing) My odt document has 2 input fields in a form. By the way, if I place a button within my form and configure the Mouse button pressed to launch, say, EnumerateTextFields then I get the following error message: LibreOffice 4.0.2.2 BASIC runtime error. '423' getTextFields and it points at the line: oEnum = oDoc.getTextFields().createEnumeration() I'm stuck on something that should be quite simple. I'm attaching my odt file hoping that someone can tell me what novice mistake I'm making. Trying to attach the file again but it seems that the mailing list strips it out. Thanks, Vieri
Re: [libreoffice-users] gettextfields
Umm, it looks like I was a few days late and you already solved your issue, so no need to send me a copy of the document :-) On 05/10/2013 12:38 AM, Andrew Douglas Pitonyak wrote: The problem is probably because these are input fields in a form. Either that, or it is because the fields are not anchored directly into the text in a way that enumerating text will display them. Can you email a copy of your document directly to me (off list). As long as it contains the text fields, that is sufficient (in other words, you can remove all the text that you like). -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette List archive: http://listarchives.libreoffice.org/global/users/ All messages sent to this list will be publicly archived and cannot be deleted
Re: [libreoffice-users] gettextfields
--- On Tue, 5/7/13, Vieri rentor...@yahoo.com wrote: --- On Mon, 5/6/13, Andrew Douglas Pitonyak and...@pitonyak.org wrote: On 05/06/2013 05:21 AM, Vieri wrote: Hi, I have an odt writer document with 2 input text fields (added with the form designer toolbar). I manually type text into one of the fields. I copy/pasted a macro to see if I could grab the text within the input field but haven't had any luck. This is the test macro in Basic: Sub EnumerateFields vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then If vEnum.hasMoreElements() Then Print OK Else Print NOT OK End If End If End Sub If I manually run this macro I get the NOT OK message. What am I doing wrong? What is the correct way of getting the text field elements? Thanks Vieri I grabbed these two routines from my test modules without running them first Hi, Thanks for the reply but I'm still having trouble. I'm either way off-course, misusing LO or making a dumb rookie mistake. I copied your macros to my odt document. I then did a tools, macros, run macro... and selected the Subs I copied. If I run EnumerateTextFields then it yields the Finished message box (nothing else). If I run DisplayMasterFields then it yields the following message: ===Text Field Masters=== (com.sun.star.text.fieldmaster.SetExpression.Illustration,Illustration) (com.sun.star.text.fieldmaster.SetExpression.Table,Table) (com.sun.star.text.fieldmaster.SetExpression.Text,Text) (com.sun.star.text.fieldmaster.SetExpression.Drawing,Drawing) My odt document has 2 input fields in a form. By the way, if I place a button within my form and configure the Mouse button pressed to launch, say, EnumerateTextFields then I get the following error message: LibreOffice 4.0.2.2 BASIC runtime error. '423' getTextFields and it points at the line: oEnum = oDoc.getTextFields().createEnumeration() I'm stuck on something that should be quite simple. I'm attaching my odt file hoping that someone can tell me what novice mistake I'm making. Trying to attach the file again but it seems that the mailing list strips it out. Thanks, Vieri -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette List archive: http://listarchives.libreoffice.org/global/users/ All messages sent to this list will be publicly archived and cannot be deleted
Re: [libreoffice-users] gettextfields
I've created two Text Boxes in a form in a writer document. I can iterate over them like this grabbing the text as I go Sub EnumerateFields oDoc = ThisComponent oDrawPage = oDoc.DrawPage oForm = oDrawPage.Forms.GetByIndex(0) For i = 0 To oForm.getCount()-1 x = oForm.getByIndex(i) Print x.getName() : x.Text Next End Sub Does this help in anyway? Iain On Wednesday 08 May 2013 01:50:02 Vieri wrote: --- On Tue, 5/7/13, Vieri rentor...@yahoo.com wrote: --- On Mon, 5/6/13, Andrew Douglas Pitonyak and...@pitonyak.org wrote: On 05/06/2013 05:21 AM, Vieri wrote: Hi, I have an odt writer document with 2 input text fields (added with the form designer toolbar). I manually type text into one of the fields. I copy/pasted a macro to see if I could grab the text within the input field but haven't had any luck. This is the test macro in Basic: Sub EnumerateFields vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then If vEnum.hasMoreElements() Then Print OK Else Print NOT OK End If End If End Sub If I manually run this macro I get the NOT OK message. What am I doing wrong? What is the correct way of getting the text field elements? Thanks Vieri I grabbed these two routines from my test modules without running them first Hi, Thanks for the reply but I'm still having trouble. I'm either way off-course, misusing LO or making a dumb rookie mistake. I copied your macros to my odt document. I then did a tools, macros, run macro... and selected the Subs I copied. If I run EnumerateTextFields then it yields the Finished message box (nothing else). If I run DisplayMasterFields then it yields the following message: ===Text Field Masters=== (com.sun.star.text.fieldmaster.SetExpression.Illustration,Illustration) (com.sun.star.text.fieldmaster.SetExpression.Table,Table) (com.sun.star.text.fieldmaster.SetExpression.Text,Text) (com.sun.star.text.fieldmaster.SetExpression.Drawing,Drawing) My odt document has 2 input fields in a form. By the way, if I place a button within my form and configure the Mouse button pressed to launch, say, EnumerateTextFields then I get the following error message: LibreOffice 4.0.2.2 BASIC runtime error. '423' getTextFields and it points at the line: oEnum = oDoc.getTextFields().createEnumeration() I'm stuck on something that should be quite simple. I'm attaching my odt file hoping that someone can tell me what novice mistake I'm making. Trying to attach the file again but it seems that the mailing list strips it out. Thanks, Vieri -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette List archive: http://listarchives.libreoffice.org/global/users/ All messages sent to this list will be publicly archived and cannot be deleted
Re: [libreoffice-users] gettextfields
Thanks! Making progress... finally. Your code actually retrieved the text within my first text box (which is at least something!) but then it fails with the error: LibreOffice 4.0.2.2 BASIC runtime error. '423' Text it points to line: Print x.getName() : x.Text It may be choking on a formatted field within the document. Just out of curiosity, how did you know that you had to use ThisComponent.DrawPage.Forms? As a novice, I find the documentation to be quite confusing and a supposedly simple task such as getting text field values seems to be quite difficult. I mean, I found examples on the net and they all start with something like: vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then Do While vEnum.hasMoreElements() vVal = vEnum.nextElement() but then I either don't know how to continue or the examples I found on the net don't work (maybe outdated OO or LO versions). BTW, is there an IDE that can auto-complete Basic code (eg. vVal.??? as in the example above). Thanks, Vieri --- On Wed, 5/8/13, mcmurchy1917-libreoff...@yahoo.co.uk mcmurchy1917-libreoff...@yahoo.co.uk wrote: I've created two Text Boxes in a form in a writer document. I can iterate over them like this grabbing the text as I go Sub EnumerateFields oDoc = ThisComponent oDrawPage = oDoc.DrawPage oForm = oDrawPage.Forms.GetByIndex(0) For i = 0 To oForm.getCount()-1 x = oForm.getByIndex(i) Print x.getName() : x.Text Next End Sub Does this help in anyway? Iain On Wednesday 08 May 2013 01:50:02 Vieri wrote: --- On Tue, 5/7/13, Vieri rentor...@yahoo.com wrote: --- On Mon, 5/6/13, Andrew Douglas Pitonyak and...@pitonyak.org wrote: On 05/06/2013 05:21 AM, Vieri wrote: Hi, I have an odt writer document with 2 input text fields (added with the form designer toolbar). I manually type text into one of the fields. I copy/pasted a macro to see if I could grab the text within the input field but haven't had any luck. This is the test macro in Basic: Sub EnumerateFields vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then If vEnum.hasMoreElements() Then Print OK Else Print NOT OK End If End If End Sub If I manually run this macro I get the NOT OK message. What am I doing wrong? What is the correct way of getting the text field elements? Thanks Vieri I grabbed these two routines from my test modules without running them first Hi, Thanks for the reply but I'm still having trouble. I'm either way off-course, misusing LO or making a dumb rookie mistake. I copied your macros to my odt document. I then did a tools, macros, run macro... and selected the Subs I copied. If I run EnumerateTextFields then it yields the Finished message box (nothing else). If I run DisplayMasterFields then it yields the following message: ===Text Field Masters=== (com.sun.star.text.fieldmaster.SetExpression.Illustration,Illustration) (com.sun.star.text.fieldmaster.SetExpression.Table,Table) (com.sun.star.text.fieldmaster.SetExpression.Text,Text) (com.sun.star.text.fieldmaster.SetExpression.Drawing,Drawing) My odt document has 2 input fields in a form. By the way, if I place a button within my form and configure the Mouse button pressed to launch, say, EnumerateTextFields then I get the following error message: LibreOffice 4.0.2.2 BASIC runtime error. '423' getTextFields and it points at the line: oEnum = oDoc.getTextFields().createEnumeration() I'm stuck on something that should be quite simple. I'm attaching my odt file hoping that someone can tell me what novice mistake I'm making. Trying to attach the file again but it seems that the mailing list strips it out. Thanks, Vieri -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette List archive: http://listarchives.libreoffice.org/global/users/ All messages sent to this list will be publicly archived and cannot be deleted -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette List archive: http://listarchives.libreoffice.org/global/users/ All messages sent to this list will be publicly archived and cannot be deleted
Re: [libreoffice-users] gettextfields
Vieri , pleasqe find some working code below hope it helps: so every field has a Placeholder property who correspondents with the data who commes here from a beamer Dim aTextFields as Object Dim i as integer Dim CurElement as Object 'xray.xray oDocument aTextfields = oDocument.getTextfields.CreateEnumeration While aTextFields.hasmoreElements' CurElement = aTextField.NextElement If CurElement.PropertySetInfo.hasPropertybyName(PlaceHolder)Then If (CurElement.PlaceHolder = Lezers) Then CurElement.getAnchor.setString(sLezers) ElseIf (CurElement.PlaceHolder = Mag) Then CurElement.getAnchor.setString(sNaam) ElseIf (CurElement.PlaceHolder = Half) Then CurElement.getAnchor.setString(sHalf) Elseif (CurElement.PlaceHolder = Voll) Then CurElement.getAnchor.setString(sVoll) Elseif (CurElement.PlaceHolder = pr1) Then CurElement.getAnchor.setString(sPr1) Elseif (CurElement.PlaceHolder = prH) Then CurElement.getAnchor.setString(sPrH) Elseif (CurElement.PlaceHolder = prV) Then CurElement.getAnchor.setString(sPrV) Elseif (CurElement.PlaceHolder = advprijs1) Then CurElement.getAnchor.setString(sadvprijs1) Elseif (CurElement.PlaceHolder = ipvprijs1) Then CurElement.getAnchor.setString(sipvprijs1) Elseif (CurElement.PlaceHolder = 1jaargang) Then CurElement.getAnchor.setString(s1jaargang) Elseif (CurElement.PlaceHolder = btw6_1) Then CurElement.getAnchor.setString(sbtw6_1) Elseif (CurElement.PlaceHolder = totaal1) Then CurElement.getAnchor.setString(stotaal1) Elseif (CurElement.PlaceHolder = advprijs2) Then CurElement.getAnchor.setString(sadvprijs2) Elseif (CurElement.PlaceHolder = ipvprijs2) Then CurElement.getAnchor.setString(sipvprijs2) Elseif (CurElement.PlaceHolder = 2jaargang) Then CurElement.getAnchor.setString(s2jaargang) Elseif (CurElement.PlaceHolder = btw6_2) Then CurElement.getAnchor.setString(sbtw6_2) Elseif (CurElement.PlaceHolder = totaal2) Then CurElement.getAnchor.setString(stotaal2) Endif End if Wend Endif Thanks! Making progress... finally. Your code actually retrieved the text within my first text box (which is at least something!) but then it fails with the error: LibreOffice 4.0.2.2 BASIC runtime error. '423' Text it points to line: Print x.getName() : x.Text It may be choking on a formatted field within the document. Just out of curiosity, how did you know that you had to use ThisComponent.DrawPage.Forms? As a novice, I find the documentation to be quite confusing and a supposedly simple task such as getting text field values seems to be quite difficult. I mean, I found examples on the net and they all start with something like: vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then Do While vEnum.hasMoreElements() vVal = vEnum.nextElement() but then I either don't know how to continue or the examples I found on the net don't work (maybe outdated OO or LO versions). BTW, is there an IDE that can auto-complete Basic code (eg. vVal.??? as in the example above). Thanks, Vieri --- On Wed, 5/8/13, mcmurchy1917-libreoff...@yahoo.co.uk mcmurchy1917-libreoff...@yahoo.co.uk wrote: I've created two Text Boxes in a form in a writer document. I can iterate over them like this grabbing the text as I go Sub EnumerateFields oDoc = ThisComponent oDrawPage = oDoc.DrawPage oForm = oDrawPage.Forms.GetByIndex(0) For i = 0 To oForm.getCount()-1 x = oForm.getByIndex(i) Print x.getName() : x.Text Next End Sub Does this help in anyway? Iain On Wednesday 08 May 2013 01:50:02 Vieri wrote: --- On Tue, 5/7/13, Vieri rentor...@yahoo.com wrote: --- On Mon, 5/6/13, Andrew Douglas Pitonyak and...@pitonyak.org wrote: On 05/06/2013 05:21 AM, Vieri wrote: Hi, I have an odt writer document with 2 input text fields (added with the form designer toolbar). I manually type text into one of the fields. I copy/pasted a macro to see if I could grab the text within the input field but haven't had any luck. This is the test macro in Basic: Sub EnumerateFields vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then If vEnum.hasMoreElements() Then Print OK Else Print NOT OK End If
Re: [libreoffice-users] gettextfields
Hi :) You might find it well worth buying the 3rd party guide produced by Andrew Pitonyak. This link helps get you there https://wiki.documentfoundation.org/Documentation/Other_Documentation_and_Resources#Programmers Andrew works hard on this list and in the Docs Team to help people with bitsbobs of code as do other people on this list but the book brings it all together rather well. It might be a good investment. I'm not sure how badly it is affected by alleged changes in the newer version of LO Basic being used by 4.0.0 and beyond but i suspect the book gives such a good overview that changes in the details are easy to figure out. Regards from Tom ) From: Vieri rentor...@yahoo.com To: users@global.libreoffice.org; mcmurchy1917-libreoff...@yahoo.co.uk Sent: Wednesday, 8 May 2013, 12:16 Subject: Re: [libreoffice-users] gettextfields Thanks! Making progress... finally. Your code actually retrieved the text within my first text box (which is at least something!) but then it fails with the error: LibreOffice 4.0.2.2 BASIC runtime error. '423' Text it points to line: Print x.getName() : x.Text It may be choking on a formatted field within the document. Just out of curiosity, how did you know that you had to use ThisComponent.DrawPage.Forms? As a novice, I find the documentation to be quite confusing and a supposedly simple task such as getting text field values seems to be quite difficult. I mean, I found examples on the net and they all start with something like: vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then Do While vEnum.hasMoreElements() vVal = vEnum.nextElement() but then I either don't know how to continue or the examples I found on the net don't work (maybe outdated OO or LO versions). BTW, is there an IDE that can auto-complete Basic code (eg. vVal.??? as in the example above). Thanks, Vieri --- On Wed, 5/8/13, mcmurchy1917-libreoff...@yahoo.co.uk mcmurchy1917-libreoff...@yahoo.co.uk wrote: I've created two Text Boxes in a form in a writer document. I can iterate over them like this grabbing the text as I go Sub EnumerateFields oDoc = ThisComponent oDrawPage = oDoc.DrawPage oForm = oDrawPage.Forms.GetByIndex(0) For i = 0 To oForm.getCount()-1 x = oForm.getByIndex(i) Print x.getName() : x.Text Next End Sub Does this help in anyway? Iain On Wednesday 08 May 2013 01:50:02 Vieri wrote: --- On Tue, 5/7/13, Vieri rentor...@yahoo.com wrote: --- On Mon, 5/6/13, Andrew Douglas Pitonyak and...@pitonyak.org wrote: On 05/06/2013 05:21 AM, Vieri wrote: Hi, I have an odt writer document with 2 input text fields (added with the form designer toolbar). I manually type text into one of the fields. I copy/pasted a macro to see if I could grab the text within the input field but haven't had any luck. This is the test macro in Basic: Sub EnumerateFields vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then If vEnum.hasMoreElements() Then Print OK Else Print NOT OK End If End If End Sub If I manually run this macro I get the NOT OK message. What am I doing wrong? What is the correct way of getting the text field elements? Thanks Vieri I grabbed these two routines from my test modules without running them first Hi, Thanks for the reply but I'm still having trouble. I'm either way off-course, misusing LO or making a dumb rookie mistake. I copied your macros to my odt document. I then did a tools, macros, run macro... and selected the Subs I copied. If I run EnumerateTextFields then it yields the Finished message box (nothing else). If I run DisplayMasterFields then it yields the following message: ===Text Field Masters=== (com.sun.star.text.fieldmaster.SetExpression.Illustration,Illustration) (com.sun.star.text.fieldmaster.SetExpression.Table,Table) (com.sun.star.text.fieldmaster.SetExpression.Text,Text) (com.sun.star.text.fieldmaster.SetExpression.Drawing,Drawing) My odt document has 2 input fields in a form. By the way, if I place a button within my form and configure the Mouse button pressed to launch, say, EnumerateTextFields then I get the following error message: LibreOffice 4.0.2.2 BASIC runtime error. '423' getTextFields and it points at the line: oEnum = oDoc.getTextFields().createEnumeration() I'm stuck on something that should be quite simple. I'm attaching my odt file hoping that someone can tell me what novice mistake I'm making. Trying
Re: [libreoffice-users] gettextfields
--- On Mon, 5/6/13, Andrew Douglas Pitonyak and...@pitonyak.org wrote: On 05/06/2013 05:21 AM, Vieri wrote: Hi, I have an odt writer document with 2 input text fields (added with the form designer toolbar). I manually type text into one of the fields. I copy/pasted a macro to see if I could grab the text within the input field but haven't had any luck. This is the test macro in Basic: Sub EnumerateFields vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then If vEnum.hasMoreElements() Then Print OK Else Print NOT OK End If End If End Sub If I manually run this macro I get the NOT OK message. What am I doing wrong? What is the correct way of getting the text field elements? Thanks Vieri I grabbed these two routines from my test modules without running them first Hi, Thanks for the reply but I'm still having trouble. I'm either way off-course, misusing LO or making a dumb rookie mistake. I copied your macros to my odt document. I then did a tools, macros, run macro... and selected the Subs I copied. If I run EnumerateTextFields then it yields the Finished message box (nothing else). If I run DisplayMasterFields then it yields the following message: ===Text Field Masters=== (com.sun.star.text.fieldmaster.SetExpression.Illustration,Illustration) (com.sun.star.text.fieldmaster.SetExpression.Table,Table) (com.sun.star.text.fieldmaster.SetExpression.Text,Text) (com.sun.star.text.fieldmaster.SetExpression.Drawing,Drawing) My odt document has 2 input fields in a form. By the way, if I place a button within my form and configure the Mouse button pressed to launch, say, EnumerateTextFields then I get the following error message: LibreOffice 4.0.2.2 BASIC runtime error. '423' getTextFields and it points at the line: oEnum = oDoc.getTextFields().createEnumeration() I'm stuck on something that should be quite simple. I'm attaching my odt file hoping that someone can tell me what novice mistake I'm making. Thanks, Vieri -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette List archive: http://listarchives.libreoffice.org/global/users/ All messages sent to this list will be publicly archived and cannot be deleted
[libreoffice-users] gettextfields
Hi, I have an odt writer document with 2 input text fields (added with the form designer toolbar). I manually type text into one of the fields. I copy/pasted a macro to see if I could grab the text within the input field but haven't had any luck. This is the test macro in Basic: Sub EnumerateFields vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then If vEnum.hasMoreElements() Then Print OK Else Print NOT OK End If End If End Sub If I manually run this macro I get the NOT OK message. What am I doing wrong? What is the correct way of getting the text field elements? Thanks Vieri -- To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/ Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette List archive: http://listarchives.libreoffice.org/global/users/ All messages sent to this list will be publicly archived and cannot be deleted
Re: [libreoffice-users] gettextfields
On 05/06/2013 05:21 AM, Vieri wrote: Hi, I have an odt writer document with 2 input text fields (added with the form designer toolbar). I manually type text into one of the fields. I copy/pasted a macro to see if I could grab the text within the input field but haven't had any luck. This is the test macro in Basic: Sub EnumerateFields vEnum = ThisComponent.getTextFields().createEnumeration() If Not IsNull(vEnum) Then If vEnum.hasMoreElements() Then Print OK Else Print NOT OK End If End If End Sub If I manually run this macro I get the NOT OK message. What am I doing wrong? What is the correct way of getting the text field elements? Thanks Vieri I grabbed these two routines from my test modules without running them first so I have no idea what state they are in, but without taking the time to create a test document and such. Perhaps these will help you. I don't even know why I have them. Probably have better coverage in OOME_3.odt or AndrewMacro.odt (but I did not check). REM Author: Andrew Pitonyak Sub EnumerateTextFields(Optional oUseDoc) Dim oDoc 'Document to use. Dim oEnum 'Enumeration of the text fields. Dim oField'Enumerated text field. Dim s$'Generic string variable. Dim n%'Count the number of text fields. Dim nUnknown% 'Count the unexpected field types. Dim bDisplayExpressions As Boolean bDisplayExpressions = True If IsMissing(oUseDoc) Then oDoc = ThisComponent Else oDoc = oUseDoc End If oEnum = oDoc.getTextFields().createEnumeration() If IsNull(oEnum) Then Print getTextFields().createEnumeration() returns NULL Exit Sub End If Do While oEnum.hasMoreElements() oField = oEnum.nextElement() If oField.supportsService(com.sun.star.text.TextField.Input) Then REM If you update Content, use oDoc.TextFields.refresh() afterwards. n = n + 1 s = s Input ( oField.getPropertyValue(Hint) , _ oField.getPropertyValue(Content) ) CHR$(10) ElseIf oField.supportsService(com.sun.star.text.TextField.User) Then REM You can update the text master field, but be certain to use REM oDoc.TextFields.refresh() afterwards. n = n + 1 s = s User ( oField.TextFieldMaster.Name , _ oField.TextFieldMaster.Value , _ oField.TextFieldMaster.InstanceName ) CHR$(10) ElseIf oField.supportsService(com.sun.star.text.TextField.PageNumber) Then REM Ignore page number fields ElseIf oField.supportsService(com.sun.star.text.TextField.GetReference) Then REM Ignore references to Listings, Tables, and Figures because I want to. If oField.SourceName Listing AND oField.SourceName Table AND oField.SourceName Figure Then n = n + 1 s = s Reference ( oField.SourceName , oField.getPresentation(False) ) CHR$(10) End If ElseIf oField.supportsService(com.sun.star.text.TextField.SetExpression) Then REM This includes things such as Tables, Listing, and Figures REM The values will be similar to SetExpression (Table, Table + 1) If bDisplayExpressions Then n = n + 1 s = s SetExpression ( oField.VariableName , oField.Content ) CHR$(10) Inspect oField End If ElseIf oField.supportsService(com.sun.star.text.TextField.Chapter) OR _ oField.supportsService(com.sun.star.text.TextField.DocInfo.Title) OR _ oField.supportsService(com.sun.star.text.TextField.DocInfo.ChangeDateTime) OR _ oField.supportsService(com.sun.star.text.TextField.Bibliography) OR _ oField.supportsService(com.sun.star.text.TextField.Annotation) Then n = n + 1 s = s oField.getPresentation(True) : oField.getPresentation(False) CHR$(10) Else nUnknown = nUnknown + 1 n = n + 1 If nUnknown = 1 Then inspect(oField) s = s Unknown : oField.getPresentation(True) : oField.getPresentation(False) CHR$(10) End If If n 50 Then MsgBox s, 0, Text Fields s = n = 0 End If Loop If n 0 Then MsgBox s, 0, Text Fields s = n = 0 End If If nUnknown 0 Then Print FoundnUnknown unexpected field types Print Finished End Sub Sub DisplayMasterFields(Optional oUseDoc) Dim oMasters 'Text field masters from the document. Dim sNames() 'Text field master names. Dim i% 'Generic loop variable. Dim sVal$ Dim s$ 'Generic string variable. Dim oMasterField 'A particular master field. Dim sUserType$ 'Holds the name for a User defined text field master sUserType = com.sun.star.text.FieldMaster.User If IsMissing(oUseDoc) Then oMasters = ThisComponent.getTextFieldMasters() Else oMasters = oUseDoc.getTextFieldMasters() End If sNames() = oMasters.getElementNames() s = ===Text Field Masters=== For i = LBound(sNames()) to UBound(sNames()) s = s Chr$(13) ( sNames(i)