Dynamc Help VBS translation - InfoPath Dev
in

InfoPath Dev

Dynamc Help VBS translation

Last post 08-05-2008 06:07 AM by ben.oates. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 08-04-2008 06:02 AM

    Dynamc Help VBS translation

    Hi,

    I am having trouble converting a bit of JScript code I got from a colleague (which I think he got from here) into VBScript. The code had already been modified from the original but I'm losing it in translation.

    In JScript, the code works by testing this line in the if statement:

    oHTMLDoc.item(eventObj.Context.nodeName)

    I can not find the equivalent in VBScript no matter how much I google! I don't have intellisense but I did have a look through the values in Watch to give me some ideas... and I'm still very lost.

    Can anyone help please?

    Dim helpString

    Sub XDocument_OnContextChange(eventObj)

    If eventObj.Type = "ContextNode" Then

    'Retrieve html object for task pane. oHTMLDoc = XDocument.View.Window.TaskPanes.Item(0).HTMLDocument.all 'Clear previous help topic from task pane

    if (helpString) then oHTMLDoc.document.body.childItem(helpString).style.display="none"

    'if the field does have an entry in the HTML i.e. it's not null

    if oHTMLDoc.document.body.childItem(eventObj.Context.nodeName) <> null then

    'Keep record of string displayed, so can later be cleared.

    helpString = eventObj.Context.nodeName

    'Display corresponding HTML DIV statement having same ID as the context node name.

    oHTMLDoc.document.body.childItem(eventObj.Context.nodeName).style.display = ""

    'If there's no specific help available default to the filler div in the HTML

    else

    helpString = "filler"

    'Display corresponding HTML DIV statement having same ID as the context node name.

    oHTMLDoc.document.body.childItem(helpString).style.display=""

    End If

    Exit Sub

    End If

    End Sub

  • 08-05-2008 06:07 AM In reply to

    Re: Dynamc Help VBS translation

    Woo! The following seems to work:

    Sub XDocument_OnContextChange(eventObj)

    If eventObj.Type = "ContextNode" Then

    'Selection or context in the form has changed. Write your code here to respond to the changes.

    'Retrieve html object for task pane.

    Set oHTMLDoc = XDocument.View.Window.TaskPanes.Item(0).HTMLDocument.all

    'Clear previous help topic from task pane.

    if (helpString) then oHTMLDoc(helpString).style.display = "none"

    'if the field does not have an entry in the HTML

    if oHTMLDoc(eventObj.Context.nodeName) Is Nothing then

     

    helpString = "filler"

     

    'Display corresponding HTML DIV statement having same ID as the context node name.

    oHTMLDoc(helpString).style.display=""

    'If there's specific help available, show it

    else

     

    'Keep record of string displayed, so can later be cleared.

    helpString = eventObj.Context.nodeName

     

    'Display corresponding HTML DIV statement having same ID as the context node name.

    oHTMLDoc(eventObj.Context.nodeName).style.display = ""

     

    End If

    Exit Sub

    End If

    End Sub

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.