How to reference a text box using VBscript - InfoPath Dev
in

InfoPath Dev

How to reference a text box using VBscript

Last post 04-25-2007 09:25 PM by K.Ramana Reddy. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 04-20-2007 09:18 AM

    How to reference a text box using VBscript

    I have a button on my Infopath 2003 form that, when clicked, runs some code to pull the user's login name.  It stores this data in a variable called "user".  I would like to then push the value in "user" to a textbox called "Signature".  I realize that this shouldn't be that difficult, but am unfamiliar with InfoPath and VBscript.
  • 04-20-2007 04:41 PM In reply to

    Re: How to reference a text box using VBscript

    Someone will have to help with the conversion (it shouldn't be very different), but in JScript you would write:

    XDocument.DOM.selectSingleNode("/my:myFields/my:Signature").text = user;

  • 04-22-2007 09:40 PM In reply to

    Re: How to reference a text box using VBscript

    Hi,

    XDocument.DOM.selectSingleNode("/my:myFields/my:Signature").text = user

    This is the VB script code to send user value into Signature. 

     

    I hope this will help you.

     

    K.Ramana Reddy / http://www.ggktech.com
    India.
  • 04-23-2007 09:24 AM In reply to

    Re: How to reference a text box using VBscript

    Thank you for your fast replies.  I am anxious to your code out, however, I am getting an error with the first line of code that I already have.  Here is what it looks like:

     set x = CreateObject("WScript.network")

    user = x.UserName

    XDocument.DOM.selectSingleNode("/my:myFields/my:Signature1").text = user

     

    Any thoughts on why this code isn't working?

     

  • 04-24-2007 02:11 AM In reply to

    Re: How to reference a text box using VBscript

    Hi,

    what error you are getting?

    Did u initialize  the x and user variables as shown below? 

    Dim X
    set X = createobject("WSCRIPT.Network")
    dim user
    user=x.UserName

    I hope this will help you.

    K.Ramana Reddy / http://www.ggktech.com
    India.
  • 04-24-2007 03:52 AM In reply to

    Re: How to reference a text box using VBscript

    Hi aehicks,

     

    instead of "set x = CreateObject("WScript.network")" try

    var x = new ActiveXObject("Wscript.Network");

    It will work

    B.Shiva Prasad
    InfoPath Dev,
    http://www.ggktech.com
    India
  • 04-24-2007 08:31 AM In reply to

    Re: How to reference a text box using VBscript

    Thanks Ramana and Shiva for your help.  Unfortunately, neither solutions are working yet. When I use the following code

    Dim X
    set X = createobject("WSCRIPT.Network")
    dim user
    user=x.UserName

    I get an error that says "ActiveX component can't create object: 'WScript.Network'.

     When I use var x = new ActiveXObject("Wscript.Network"); instead of set X = createobject("WSCRIPT.Network") I get an invalid character error.  I'm guessing this is because this isn't VBscript.

     Any suggestions?  I appreciate your help.

  • 04-24-2007 12:29 PM In reply to

    Re: How to reference a text box using VBscript

    Please ignore the suggestion for using "var = new ..." that is for JScript, not VBScript. It won't work in your situation because you are using VBScript.
  • 04-25-2007 09:25 PM In reply to

    Re: How to reference a text box using VBscript

    Hi,

    I tried below code, it is worked for me, you try with this code.

    Dim X

    set X = createobject("WSCRIPT.Network") 

    XDocument.DOM.selectSingleNode("/my:myFields/my:field1").text=X.UserName

    K.Ramana Reddy / http://www.ggktech.com
    India.
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.