Consulting

Results 1 to 4 of 4

Thread: Excel VBA Code Help!!

  1. #1

    Excel VBA Code Help!!

    I am attempting to input cell A1 into a blank on a web page and that blank is within a table. Can someone help me here?

    Here is the page source:

    <html>
    <head>
    <TITLE></TITLE>
    <script language="JavaScript" SRC="../js/browsercheck.js">
    </script>

    <script language="JavaScript">
    var submitFlag = "Y"
    function doInit() {
    this.parent.user_grp = this.document.form1.wp_user_grp.value
    this.parent.sec_admin = this.document.form1.wp_sec_admin.value
    this.parent.svcr_fmly = this.document.form1.wp_svcr_fmly.value
    this.parent.mi_co = this.document.form1.wp_mi_co.value
    this.parent.outsrc_co = this.document.form1.wp_outsrc_co.value
    this.parent.lan_user_id = this.document.form1.wp_lan_user_id.value
    //alert("welcome.htm do init")
    //alert(this.parent.svcr_fmly)
    //alert(this.parent.user_grp)
    }

    </script>

    <script language="JavaScript" SRC="../js/welcome.js">
    </script>

    <script language="JavaScript" SRC="../js/wp2common.js">
    </script>

    </HEAD>

    <BODY BGCOLOR="#ffffff" VLINK="#fd0407" ALINK="#000ef3" onFocus="goBackElement(document.form1)" onLoad="doInit()">
    <center>
    <img src="../images/identifier100.gif">
    <br>
    <img SRC="../images/bar_red.gif" width="550">
    </center>

    <script language="JavaScript">
    if (isBrowserSupported() == false) {
    document.write(getBrowserWarningMessage());
    }
    </script>

    <form action="/nwp/servlet/WpServlet" method="post" name="form1" target="_top"
    onSubmit="return submit_form(this)" autocomplete="off">

    <center>

    <!--table border=1>
    <tr>
    <td><input type="radio" name="loanType" value="FM" onClick="" Checked onFocus="checkRule(this)"><B>Freddie Mac Loan</B>
    <br>
    <input type="radio" name="loanType" value="NFM" onClick="checkNonFM(document.form1)" onFocus="checkRule(this)"><B>Non Freddie Mac Loan</B>
    </td>
    </tr>
    </table-->
    <input type="hidden" name="loanType" value="FM"/>

    <br>

    <table border=1>
    <tr>
    <td>
    <table border=0>
    <tr>
    <td>Freddie Mac Loan Number:</td>
    <td><input type="text" name="wp_nbr_mrtg" size="15" maxlength="9"
    onFocus="checkRule(this)" onChange="checkLoanNum(this)">
    </td>
    </tr>
    <!--tr>
    <td>Servicer Loan Number:</td>
    <td><input type="text" name="wp_svcr_mrtg" size="15" maxlength="13" onFocus="checkRule(this)" onChange="checkLoanNum(this)"></td>
    </tr-->
    <tr>
    <td>MI Certificate Number:</td>
    <td><input type="text" name="wp_mi_cert_num" size="15" maxlength="10"
    onFocus="checkRule(this)" onChange="checkLoanNum(this)">
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </center>

    <br><br>
    <center>
    <input type="submit" name="smit" value=" Enter "
    onFocus="checkRule(this)">
    </center>

    <!-- Hidden object -->
    <input type="hidden" name="WP_FORM_SUBMITTED" value="FALSE">
    <input type="hidden" name="wp_user_grp" value="DELEGATED">
    <input type="hidden" name="wp_svcr_fmly" value="621406">
    <input type="hidden" name="wp_lan_user_id" value="norjk4">
    <input type="hidden" name="wp_mi_co" value="">
    <input type="hidden" name="wp_outsrc_co" value="">
    <input type="hidden" name="wp_sec_admin" value="N">
    <input type="hidden" name="status_msg" value="">
    <input type="hidden" name="LOGON_SCREEN">
    <input type="HIDDEN" NAME="SCREEN" value="BorrInfo" >
    <input type="HIDDEN" NAME="FRAME" value="PARENT" >
    <input type="HIDDEN" NAME="RQ_LOAN" value="FALSE" >
    <input type="HIDDEN" NAME="wp_loan" value="" >
    </form>
    </body>
    </html>



    What I want to do is enter a # from cell A1 in my spreadsheet into this area on the page:

    <td>Freddie Mac Loan Number:</td>
    <td><input type="text" name="wp_nbr_mrtg" size="15" maxlength="9"
    onFocus="checkRule(this)" onChange="checkLoanNum(this)">
    </td>

    but that blank is inside of a table and I don't know how to get it to put the number there.

    I tried something like:

    Set doc = appIE.Document
    Set htmlColl = doc.getElementsByTagName("INPUT")
    For Each htmlInput In htmlColl
    If htmlInput.Name = "wp_nbr_mrtg" Then _
    htmlInput.Value = Workbooks(1).Worksheets(1).Range("A1")

    but that didn't work

    Any ideas?

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hi there, and welcome to the board!!

    Shouldn't it be htmlInput.Text = Workbooks(1).Worksheets(1).Range("A1").Value?

    If it doesn't work, when you iterate through the controls, set it up to stop the code on the correct object and check the properties. Are you sure you're on the right textbox?

  3. #3
    Quote Originally Posted by Zack Barresse
    Hi there, and welcome to the board!!

    Shouldn't it be htmlInput.Text = Workbooks(1).Worksheets(1).Range("A1").Value?

    If it doesn't work, when you iterate through the controls, set it up to stop the code on the correct object and check the properties. Are you sure you're on the right textbox?
    Ok I got it working if I move the big frame to a window by itself.

    Now I am trying to get it working on the normal page, which has a small frame on the left and the big frame in the middle.

    I am trying this:

    Set htmlDoc = .Document.frames("Body").Document

    to have it read from the BIG frame, but it's not working.

    If I move the big frame to a window by itself:

    Set htmlDoc = .Document

    works perfectly.

    How can I make it read from the frame when its not on a page by itself?

  4. #4
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    I think you need to know the actual name of the frame and treat it as a control itself. They should have their own innerhtml as well I believe. I hate working with frames and avoid it whenever possible. I'd suggest that if you have it working in the other window, use that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •