Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index

On 9/05/2013 9:13, Vieri wrote:

--- On Thu, 5/9/13, <> 

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 =
Print x.getName() & " : " & x.Text End If
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 
i use a "create a Windows" object to do the posting "WinHttp.WinHttpRequest.5.1"

hope it helps

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 = ""; & 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
    t = oH.ResponseText

    MicrosoftTranslate = mid(t,3,len(t)-3)

    Set oH = Nothing

    Exit Function

  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 = "";

    'Client ID from
    Dim clientId As String
    clientId = "myclientid"

    'Client secret from
    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) & _

    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 Function

    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 & "+"
                TempAns = TempAns & "%" & Hex(32)
            End If
        Case Else
            TempAns = TempAns & "%" & _
            Right("0" & Hex(Asc(Mid(StringToEncode, _
            CurChr, 1))), 2)
        End Select

        CurChr = CurChr + 1
    URLEncode = TempAns

    Exit Function

   msgbox("err_catch3 " & Err & Error & Erl ,48)
    Resume exit_sub

End Function

Thanks again!


To unsubscribe e-mail to:
Posting guidelines + more:
List archive:
All messages sent to this list will be publicly archived and cannot be deleted


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.