Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am hoping someone can provide some “how to” info on using variables in a vbscript. Below is the script we using to call data from an API. We want to now be able to get data from a List Box. Any help on the coding would be much appreciated.
Thanks,
Terry.
sub GetLists()
Dim xml
Dim strXML
strXML = "<?xml version=""1.0"" encoding=""UTF-8""?>"
strXML = strXML & "<Envelope>"
strXML = strXML & "<Body>"
strXML = strXML & "<Login>"
strXML = strXML & "<USERNAME>username</USERNAME>"
strXML = strXML & "<PASSWORD>password</PASSWORD>"
strXML = strXML & "</Login>"
strXML = strXML & "<GetLists>"
strXML = strXML & "<VISIBILITY>0</VISIBILITY>"
strXML = strXML & "<LIST_TYPE>2</LIST_TYPE>"
strXML = strXML & "</GetLists>"
strXML = strXML & "</Body>"
strXML = strXML & "</Envelope>"
set xml = CreateObject("Microsoft.XMLHTTP") 'XMLHTTP is an MS object that handles xml post over http
' msgbox strXML
xml.Open "POST", "http://api.somedomain.com/XMLAPI?xml="&strXML, False
xml.Send
Path = ActiveDocument.Evaluate("left(DocumentPath(), index(DocumentPath(), '\', -1))")
FileName = Path & "GetLists.xml"
set fso = CreateObject("Scripting.FileSystemObject")
set s = fso.CreateTextFile(FileName, True)
s.writeline(xml.responseText)
s.Close()
msgbox ("Done")
end sub
This is from the API Guide:
set table = ActiveDocument.GetSheetObject( "LB01" )
CellRect = ActiveDocument.GetApplication().GetEmptyRect()
CellRect.Top = 0
CellRect.Left = 0
CellRect.Width = table.GetColumnCount
CellRect.Height = table.GetRowCount
set CellMatrix = table.GetCells( CellRect )
for RowIter=CellRect.Top to CellRect.Height-1
for ColIter=CellRect.Left to CellRect.Width-1
msgbox(CellMatrix(RowIter)(ColIter).Text)
next
next
In your macro, try this
ActiveDocument.Fields("yourfieldname").GetSelectedValues.Item(0).Text
This assumes you want the first selected item.
ws