Archive for the ‘Office’ Category

OneNote

I am getting to know OneNote now that I am a laptop user. It has been very useful in meetings and very good for organizing my thinking/working, but I learned a couple new things last week that are worth noting:

  • You can capture audio as a note. I am finding this very useful when listening to .NetRocks shows and I want to save a small part of it that I can get back to quickly. I can add my own text comments right there as well as relevant URLs, etc. Just change the audio input source to Wave Out Mix in the Options dialog box.
  • You can capture screenshots into a note (Insert Menu -> Screen Clipping). This is only in OneNote Service Pack 1. I am currently in the design phase of an application and this is very handy. I can take a screenshot into the note and then share the note in meetings with the team. You can even do this when OneNote is closed using the OneNote icon in the system tray.
Posted on:
Posted in Office | Comments Off on OneNote

Excel as a Web Service Client

As a small project, we were tasked with creating a data feed from a text report genereated by JD Edwards (not OneWorld, an older version) and our application. Instead of going the FTP and text file parsing route, I decided to try our first venture into a web service. Since the JD Edwards group were using Excel 2000 to manipulate the report before sending it to our system, I figured a VBA macro could send the data for them, using the XMLHTTP object.

‘Notes: Using late binding so the project won’t need explicit references
‘       Using MSXML 2.5 object model to be sure it will run on most PCs
Public Sub SendDataToEnCore()
    Dim oXML As Object
    Dim oDom
As Object
    Dim oNode
As Object
    Dim sXML As String
    Dim nResult As Integer
    Dim sResponse
As String
     
    On Error GoTo Handler
    Set oXML = CreateObject(“Microsoft.XMLHTTP”)
    Application.Cursor = xlWait ‘Change the cursor to a wait cursor
    Application.ScreenUpdating = False   ‘Stop screen redraw
    With oXML
         ‘Call the service, it only takes one parameter, the XML string

        .Open “POST”, & _
       
http://test.com/Redeployment.asmx/Redeployment_Update“, False
       
        ‘The following line is necessary for the web service to recognize the post
        .setRequestHeader “Content-Type”, “application/x-www-form-urlencoded”

        Application.StatusBar = “Waiting for a response…”
        ‘Create XML is a function that loops the spreadsheet building an XML string
        .Send CreateXML
 
   End With
   
    sResponse = oXML.responseText
    With Application
        .Cursor = xlDefault
        .StatusBar = “”
        .ScreenUpdating = False
    End With
    Set oDom = CreateObject(“MSXML.DOMDocument”)
    oDom.loadXML (sResponse)
   
    If oDom.hasChildNodes Then
        ‘Display the resulting message from the web service
        Set oNode = oDom.documentElement.firstChild
        nResult = MsgBox(oNode.Text, vbInformation, “EnCore Data Transfer”)
    Else ‘No response at all
        MsgBox (“The JDE upload failed. Please contact Development
for assistance.”)
   
End If
    Set oXML = Nothing
    Set oDom = Nothing
    Set oNode = Nothing
    Exit Sub
Handler:
    With Application
        .Cursor = xlDefault
        .StatusBar = “”
        .ScreenUpdating = False
    End With
    MsgBox Err.Description
    Set oXML = Nothing
    Set oDom = Nothing
    Set oNode = Nothing
End Sub

So far this has worked well for us. One of the issues we encountered was URLEncoding the XML string before sending it. Otherwise, it just won’t parse properly on the web service end. Here is an abbreviated version of the web service function that is called by the above Excel VBA function.

Public Function Redeployment_Update(Byval sInput As string) As String

    Dim dt As DataTable
   
dim n as Integer

    sInput = cstr(sInput)

    n = sInput.Length
    If n <= 0 Then
       
return “File contains no data”
   
End If

    ‘ Load the input XML string into a DataTable
    dt = LoadDataTable(sInput)

    Dim drCurrent As DataRow
    For Each drCurrent In dt.Rows
       
ProcessRow(drCurrent) ‘Our custom function to parse a row
    next

   
return “File received OK. Characters Received=” & n

End Function

Posted on:
Posted in .Net 1.1, Office | Comments Off on Excel as a Web Service Client