Using ShellExecute to send HTTP/XML file

smig

Registered User.
Local time
Today, 10:33
Joined
Nov 25, 2009
Messages
2,209
I'm trying to use ShellExecute to send an HTTP/XML file to a WEB server, but something seems to be wrong :banghead:

Here is the Shell Execute function I use:
Code:
Public Function OpenDirApp(WhatToOpen As String)

ShellExecute 0, "Open", WhatToOpen, vbNullString, vbNullString, SW_SHOWNORMAL

End Function

Here is the XML string I send:
Code:
...

strHTTP = <CreateOrUpdateTaskRequest xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
    <UserName>USER_Name</UserName>
    <Password>USER_PASS</Password>
    <Operation>AutoSelect</Operation>
    <TaskNumber>22788</TaskNumber>
    <CustomerNumber>12969</CustomerNumber>
    <EmployeeNumber>59</EmployeeNumber>
    <DueDateAsYYYYMMDDHHMMSS>20181212000000</DueDateAsYYYYMMDDHHMMSS>
    <Description>DESCRIPTION</Description>
    <Notes>NOTES</Notes>
    <Status>1</Status>
    <Phone1></Phone1>
    <CustomerName>CUST_NAME</CustomerName>
    <Location>
        <Address>CUST_ADRESS</Address>
    </Location>
    <Data1>DATA_1</Data1>
    <Data2>DATA_2</Data2>
    <Data3>DATA_3</Data3>
</CreateOrUpdateTaskRequest>

Call OpenDirApp(strHTTP)

Is there any way to get something back fro the ShellExecute ?
 
there are lots of sample sending xml on the web XMLHTTP (eg: https://codingislove.com/http-requests-excel-vba/).
just google it.
Thanks

I have this code, that I use to Download files, using XML
It works fine.

How do I change it to send the XML that I have to the server?
When I try I get an error -2147012890 (The URL address is not using a recognized address) on the marked line :confused:

Code:
Public Function fnSendHTTP(strHTTP As String, Optional strUN As String, Optional strPW As String) As Boolean

Dim xmlHTTP As Object
Dim strRespText As String

Set xmlHTTP = CreateObject("MSXML2.ServerXMLHTTP")

With xmlHTTP
    [COLOR="Red"].Open "GET", strTarget, False, strUN, strPW[/COLOR]
    .setRequestHeader "cache-control", "no-cache,must revalidate"
    .Send
    If fnSaveDownloadFile(strSaveAs, .responseBody) = False Then
        GoTo errHere
    End If
End With
 
Well strTarget doesn't exist in your function. I guess you need to change that to strHTTP
 

Users who are viewing this thread

Back
Top Bottom