一个IE窗口,有三个FRAME,分别NAME 为FRAME name=topFrame    
                                  FRAME name=leftFrame 
                                  FRAME name=main
我现在要对FRAME name=main 的三个输入框内传值.请问如何用VB来传值.请各位大哥帮忙!

解决方案 »

  1.   

    先取到三个输入框内的句柄,然后用SendMessage传值,不过取句柄不容易
      

  2.   

    http://dev.csdn.net/develop/article/17/17697.shtm
    希望对LZ有帮助
      

  3.   

    ShellWindow  自己上网搜,而且很简单
      

  4.   

    Private Sub Command1_Click()
    Dim IEList As New ShellWindows
    Dim Browse
    Dim Doc
    On Error Resume Next
    '遍历当前地浏览器窗口
    For Each Browse In IEList
    '找到需要地IE窗口If Browse.Document.Title = "testpage" Then
       
        '获得浏览器地文档对象
        Set Doc = Browse.Document
       '填写
        Doc.body.All("textfield23").Value = "123456"
        Doc.body.All("textfield22").Value = "222222"
      'End If
    End IfNextEnd Sub楼上的哥哥们详细点!但是还是填不上,我想是因为FRAME的原因. 若一个IE窗口,没有FRAME,我可以填,若有就不行.
    请大哥们帮帮忙,小妹在此感谢!
      

  5.   

    扣底给你,' Make a reference to shdovw.dll (MS internet controls) and mshtml.tlb (MS HMTL Object Library)
    Option Explicit
    Option Compare Text
    Public Sub getBrowsers()
        On Error Resume Next
        Dim ShellWins As New SHDocVw.ShellWindows
        Dim IE As New InternetExplorer
        Dim HtmlFound As Boolean
        'Dim HTMLDOC As HTMLDocument
        Dim CtlIndex As Integer
        HtmlFound = False
        For CtlIndex = 0 To ShellWins.Count - 1
            '遍历Shell窗口
            If TypeOf ShellWins.Item(CtlIndex) Is IWebBrowser2 Then
                'if is IE
                Set IE = ShellWins.Item(CtlIndex)
                'If (TypeName(IE.document) <> "Nothing") Then
                If TypeName(IE.document) = "HTMLDocument" Then
                    'HTML页面
                    If Trim(IE.document.Title) = "MCM-综合业务支撑平台测试版" Then '连接
                        '获取其上所有Frames框架
                        MsgBox "找到了HTML页"
                        getFrames IE.document
                        HtmlFound = True
                        Set IE = Nothing
                        Exit For
                    End If
                End If
                'End If
                Set IE = Nothing
            End If
        Next
        If Not HtmlFound Then
            MsgBox "没有找到对应的HTML工作页面"
            'Exit Sub
        End If
        Set ShellWins = Nothing
    End Sub
    'Public Sub getAll(ByVal HTMLDOC As HTMLDocument)
    'If HTMLDOC.getElementsByTagName("OPTION").length And HTMLDOC.getElementsByTagName("INPUT").length Then
    'if HTMLDOC has OPTIONS or INPUT then
    'MsgBox HTMLDOC.getElementsByTagName("OPTION").length '57
    'MsgBox HTMLDOC.getElementsByTagName("INPUT").length '23
    'getCtls HTMLDOC
    'End If
    'If HTMLDOC.frames.length Then getFrames HTMLDOC
    'End Sub
    Public Sub getFrames(ByRef HtmlDoc As HTMLDocument)
        On Error Resume Next
        If HtmlDoc.frames.length Then
            Dim HtmlFrame As Object, FrameFound As Boolean
            FrameFound = False
            'if has Frames on
            Dim CtlIndex As Integer
            For CtlIndex = 0 To HtmlDoc.frames.length - 1
                '遍历Frames
                If HtmlDoc.frames.Item(CtlIndex).Name = "main" Then
                    '连接工作簿
                    'If TypeName(HtmlDoc.frames.Item(CtlIndex)) = "HTMLWindow2" Then
                    Set HtmlFrame = HtmlDoc.frames.Item(CtlIndex).document
                    'If HtmlFrame.getElementsByTagName("OPTION").length And HtmlFrame.getElementsByTagName("INPUT").length Then
                    'getAll HTMLDOC.frames.Item(CtlIndex).document
                    MsgBox "找到了FRAME"
                    getCtls HtmlFrame
                    FrameFound = True
                    Set HtmlFrame = Nothing
                    Exit For
                End If
                'End If
            Next
        End If
        If Not FrameFound Then
            MsgBox "没有找到对应的工作簿文件"
        End If
    End Sub
    Public Sub getCtls(ByRef HtmlDoc As HTMLDocument)
        On Error Resume Next
        '使用select case 做
        HtmlDoc.getElementById("CustName").Value = "劳大"
        HtmlDoc.getElementById("CustAddr").Value = "劳大"
        If HtmlDoc.getElementById("CustCertType").Value = "00" Then 'Select的选择
            HtmlDoc.getElementById("CustCertType").Value = "11"
        End If
        MsgBox "done"
    End Sub
    Private Sub Command1_Click()
        getBrowsers
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        End
    End Sub
      

  6.   

    网上这方面的资料很少,
    一HTML页面,标题:MCM-综合业务支撑平台测试版
    下面一FRAME  :main
    里面有元素
    HtmlDoc.getElementById("CustName").Value = "劳大"
        HtmlDoc.getElementById("CustAddr").Value = "劳大"
        If HtmlDoc.getElementById("CustCertType").Value = "00" Then 'Select的选择
            HtmlDoc.getElementById("CustCertType").Value = "11"
        End If
    明白了吗?
      

  7.   

    谢谢 yinweihong(你走,我连一句狠话都说不出口)  哥哥!解决了!