Simon Fell > Its just code > Word 2 Story : Code

Thursday, April 12, 2001

This was a Word macro i wrote that uses PocketSOAP to create a new story in Manila.

Sub MakeStory()
    
    While (Selection.MoveStart(wdParagraph, -1) <> 0)
    Wend
    
    While (Selection.MoveEnd(wdParagraph, 1) <> 0)
    Wend
    
    Dim site, email, password
    site = InputBox("Enter URL of Manila Site", "Word 2 Story", "http://simonfell.manilasites.com/")
    email = InputBox("Enter email address", "Word 2 Story", "sf@zaks.demon.co.uk")
    password = InputBox("Enter password", "Word 2 Story", "")
    
    Dim pf, utils, siteName, st
    Set pf = CreateObject("pocketSOAP.Factory")
    Set utils = pf.createProxy(site, "", "/manila")
    siteName = utils.getSiteName(siteUrl:=site)

    ' create a message
    Set st = pf.createProxy(site, "", "/manila/message")
    Dim msg
    Set msg = st.create(UserName:=email, password:=password, siteName:=siteName, _
                Subject:="Word 2 Story", body:=Selection.Text, bodyType:="text/plain", inResponseTo:=0, _
                windowInfo:=0, rendererInfo:=0)

    ' make it a story
    st.addToStoriesList UserName:=email, password:=password, siteName:=siteName, msgNum:=msg.parameters.itembyName("msgnum").Value
    
    ' if you're using a more recent version of pocketSOAP (1.2 or later), then you need to comment out the line above
    ' and uncomment the line below
    ' st.addToStoriesList UserName:=email, password:=password, siteName:=siteName, msgNum:=msg.Nodes.itembyName("msgnum").Value
    
    MsgBox "done !"
End Sub