<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px">
</OBJECT> 
 
        ......
var a=dlgHelper.fonts.count;《---------如何在VB中对该对象进行操作啊?
                                                在网上找了好半天都没有结果郁闷...
                                                我想得到这个值dlgHelper.blockFormats.count
var fArray = new Array();
var oDropDown = oToolBar.createDropDownListAt("4");
oDropDown.setAttribute("id","FontNameList");
          ......

解决方案 »

  1.   

    set ttt=webbrowser1.document
    set nnn=ttt.getElementById("dlgHelper")
    a=ttt.fonts.count用webbrowser控件的话
      

  2.   

    若不用webbrowser控件如何实现啊?^_^
      

  3.   

    &_& 呵呵 还是不行set nnn=ttt.getElementById("dlgHelper") 对象变量或 With 块变量没有设置(错误 91)
      

  4.   

    Private Sub Command1_Click()
    Set ttt = WebBrowser1.Document
    Set nnn = ttt.getElementById("WindowsMediaPlayer1")
    End SubPrivate Sub Form_Load()
    WebBrowser1.Navigate "file:///E:/vb/webtry/index.htm"
    End Sub<html><head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 1</title>
    </head><body><p>
    <object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="WindowsMediaPlayer1">
      <param name="URL" value>
      <param name="rate" value="1">
      <param name="balance" value="0">
      <param name="currentPosition" value="0">
      <param name="defaultFrame" value>
      <param name="playCount" value="1">
      <param name="autoStart" value="-1">
      <param name="currentMarker" value="0">
      <param name="invokeURLs" value="-1">
      <param name="baseURL" value>
      <param name="volume" value="50">
      <param name="mute" value="0">
      <param name="uiMode" value="full">
      <param name="stretchToFit" value="0">
      <param name="windowlessVideo" value="0">
      <param name="enabled" value="-1">
      <param name="enableContextMenu" value="-1">
      <param name="fullScreen" value="0">
      <param name="SAMIStyle" value>
      <param name="SAMILang" value>
      <param name="SAMIFilename" value>
      <param name="captioningID" value>
      <param name="enableErrorDialogs" value="0">
      <param name="_cx" value="6482">
      <param name="_cy" value="6350">
    </object>
    </p></body></html>用mediaplayer写的,怀疑你自己写错了,如果html可以用这个id的话,我的方法一定没有错的
      

  5.   

    Private sPara       As Object
    Private nPara       As Object....................
    Private Sub Form_Load()
        
        Dim a           As Integer
        Dim i           As Integer
          
        web.Navigate "about: blank"        '设置空白页
        
        web.Document.Open                  '写入当前可编辑内容
        web.Document.write "<HTML><HEAD><TITLE>ZCM's PRM</TITLE></HEAD><BODY STYLE='overflow:hidden; margin:0px'></BODY></HTML>"
        
        Set sPara = web.Document
        Set nPara = sPara.getElementById("dlgHelper")    '调用dlghelper对象
        
        '初始化时将代码写到txtbox中
        OutHtmlTxt = web.Document.All(0).outerHTML
        
        a = nPara.BlockFormats.Count
         '初始化格式列表框
        For i = 1 To a
            
            With Paragraphcob
                .AddItem nPara.BlockFormats(i)
                .Text = .List(0)
            End With
        
        Next
        
    End Sub
      

  6.   

    加上<OBJECT ID=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" WIDTH="0px" HEIGHT="0px"></OBJECT>后
    显示Run-time error'-2147417848(80010108)' ;
    automation error the object invoked has disconnected from its clients. 也就是自动化错误....
      

  7.   

    web.Navigate "about: blank"        '设置空白页
        
        web.Document.Open                  '写入当前可编辑内容
        web.Document.write "<HTML><HEAD><TITLE>ZCM's PRM</TITLE></HEAD><BODY STYLE='overflow:hidden; margin:0px'></BODY></HTML>"
        
        Set sPara = web.Document
        Set nPara = sPara.getElementById("dlgHelper")    '调用dlghelper对象这个是当然的了,你的object还没加载呢,哪找id给你调用的
      

  8.   

    加上<OBJECT ID=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" WIDTH="0px" HEIGHT="0px"></OBJECT>后
    显示Run-time error'-2147417848(80010108)' ;
    automation error the object invoked has disconnected from its clients. 也就是自动化错误....
    ==========================================================================================
    加载后  这条不能运行a = nPara.BlockFormats.Count 显示自动化错误
      

  9.   

    你能不能先写个静态的页面,用webbrowser.navigate转向,然后在complete之后再调用的??
      

  10.   

    我在做的是网页编辑器,所以无法用静态页转向,我是这样认为的,在初始化时直接建立一个固有的htm页面和先写个静态的页面是一样的道理啊-_-
      

  11.   

    Private Sub Form_Load()
        WebBrowser1.Navigate "about: blank"        '设置空白页
        WebBrowser1.Document.Open                  '写入当前可编辑内容
        WebBrowser1.Document.write "<HTML><HEAD><TITLE>ZCM's PRM</TITLE></HEAD><BODY STYLE='overflow:hidden; margin:0px'><object classid='clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6' id='WindowsMediaPlayer1'></object></BODY></HTML>"
       Set ttt = WebBrowser1.Document
       Set nnn = ttt.getElementById("WindowsMediaPlayer1")
    End Sub这个也能通过,能不能用getElementbyid是看你加没加载的,我是怀疑你几次都没加载成功
      

  12.   

    你这个ocx是什么东东啊??从哪能下来的??我试验一下的
      

  13.   

    Add the object element at the top of the BODY section to create the Dialog Helper object. You must have Internet Explorer 6 or later to complete this step and subsequent steps. 
     <OBJECT ID=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b"
     WIDTH="0px" HEIGHT="0px"></OBJECT>据说ie6上自带的
      

  14.   

    Private Sub Form_Load()
    WebBrowser1.Navigate "about: blank"        '设置空白页
        WebBrowser1.Document.Open                  '写入当前可编辑内容
        WebBrowser1.Document.write "<HTML><HEAD><TITLE>ZCM's PRM</TITLE></HEAD><BODY STYLE='overflow:hidden; margin:0px'><OBJECT ID='dlgHelper' CLASSID='clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b' WIDTH='0px' HEIGHT='0px'></OBJECT></BODY></HTML>"
       Set ttt = WebBrowser1.Document
       Set nnn = ttt.getElementById("dlgHelper")End Sub测试通过,我晕,你是什么地方出问题了??
      

  15.   

    我知道了,是没有加载的缘故,这样就没有问题了,所以建议用documentcomplete事件去做这个的调用现在用这个按钮就不会出错了Private Sub Command1_Click()
    Set ttt = WebBrowser1.Document
       Set nnn = ttt.getElementById("dlgHelper")
        a = nnn.Fonts.Count
    End SubPrivate Sub Form_Load()WebBrowser1.Navigate "about: blank"        '设置空白页
        WebBrowser1.Document.Open                  '写入当前可编辑内容
        WebBrowser1.Document.write "<HTML><HEAD><TITLE>ZCM's PRM</TITLE></HEAD><BODY STYLE='overflow:hidden; margin:0px'><OBJECT ID='dlgHelper' CLASSID='clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b' WIDTH='200px' HEIGHT='200px'></OBJECT></BODY></HTML>"
       
    End Sub
      

  16.   

    documentcomplete中不行
    用command可以,但是不是我所要达到的效果
    用一个静态页加载的方法也不行
    与command组和使用也不行.......
      

  17.   

    用sleep 在 Form_Load里调用都不行只好用一个timer控件进行列表框的初始化了。Private Sub Timer1_Timer()    '这里这么写不会影响运行速度才怪呢~_~...
        Call Command1_Click
        Timer1.Enabled = False
        
        web.Document.execCommand "editMode"End SubPrivate Sub Command1_Click()   '不可见的,在xxx的下层
        
        Set sPara = web.Document
        Set nPara = sPara.getElementById("dlgHelper")    '调用dlghelper对象
        
        a = nPara.BlockFormats.Count
        
         '初始化格式列表框
        With Paragraphcob
            For i = 1 To a
                    .AddItem nPara.BlockFormats(i)
            Next
        End With
        '初始化系统字体
        a = nPara.Fonts.Count
        
        With FontNamecob
            
            For i = 1 To a
                .AddItem nPara.Fonts(i)
                DoEvents
            Next
        
        End With
        
    End Sub希望能够找到合适的调用...
      

  18.   

    //callColorDlg uses the dialog helper object's ChooseColorDlg method to open the color dialog box, then changes the font or back color of the selected text
    function callColorDlg(sColorType){if (sInitColor == null) 
    //display color dialog box
    var sColor = dlgHelper.ChooseColorDlg();
    else
    var sColor = dlgHelper.ChooseColorDlg(sInitColor);
    //change decimal to hex
    sColor = sColor.toString(16);
    //add extra zeroes if hex number is less than 6 digits
    if (sColor.length < 6) {
       var sTempString = "000000".substring(0,6-sColor.length);
       sColor = sTempString.concat(sColor);
    }
    //change color of the selected text
    document.execCommand(sColorType, false, sColor);
    sInitColor = sColor;
    oDiv.focus();
    }
    这个如何翻译成VB啊? 我翻译了半天也不能执行郁闷大概是dlgHelper.ChooseColorDlg不执行..
      

  19.   

    这段已经搞定了。^_^ 调用自带的调色板然后把色彩赋给
    '颜色相关执行
    Public Function callColorDlg(sColorType As String, scolor As Long)
      
      WebEditFrm.web.Document.execCommand sColorType, False, scolorEnd Function
    这个函数就ok了
      

  20.   

    问题又来了
    如何插入DIV 或者 TABLE 阿?就是如何获得当前鼠标所在元素的id啊?
      

  21.   

    set ttt=webbrowser1.document
    set nnn=ttt.createElement("div")给你个vbs的例子function init()set ttt=document.getElementById("sele1")
     For i = 1To 50
            Set oOption = document.createElement("OPTION")
            oOption.Value = i
            oOption.text = i
            
            ttt.Add oOption
            Set oOption = Nothing
        Next
      

  22.   

    我的意思是说在可编辑的webbrowser1中任意一个地方(比如两个表的中间)插入HTML比如下例插入Flashfunction ReturnValue(){
    var sFromUrl = d_fromurl.value;
    var sWidth = d_width.value;
    var sHeight = d_height.value;

    var sHTML = "<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
    if (sWidth!="") sHTML+=" width="+sWidth;
    if (sHeight!="") sHTML+=" height="+sHeight;
    sHTML+="><PARAM NAME=movie VALUE='"+sFromUrl+"'><PARAM NAME=quality VALUE=high><embed src='"+sFromUrl+"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash'";
    if (sWidth!="") sHTML+=" width="+sWidth;
    if (sHeight!="") sHTML+=" height="+sHeight;
    sHTML+=">"+sFromUrl+"</embed></OBJECT>";

    dialogArguments.insertHTML(sHTML);        <<-------------------这里不知道如何实现 window.returnValue = null;
    window.close();
    }
      

  23.   

    不要把js写成这样,你用webbrowser又不用firefox的,尽量用dom的你可以用createElementinsertbefore多种方法啊,比innerhtml更容易写出有结构性的东西,否则你这么个代码你不觉得乱啊??还有为什么不用vbs写客户端的,webbrowser对vbs的支持比对js的支持要好的多
      

  24.   

    那个只是我仿照的例程;我的目的是写一个编辑HTML的编辑器而已.由于手头只有这些资料;所以才这样写的-_-|||  createElement 您能给一个实例吗  插入 table的 和 插入 div的  谢谢   ^_^  为了答谢你 我将令开个200分贴
      

  25.   

    当Document.execCommand "editMode" 时 即为 可编辑状态;可以任意位置插入table 修改table ; 您有这方面的资料吗^_^ 我快郁闷死了
      

  26.   

    终于从MSDN中找到了这是我写的'在当前位置插入基本对象
    Public Function insertHTML(html As String)    Dim doc       As IHTMLDocument2
        Set doc = WebEditFrm.web.Document
        
        If LCase(doc.selection.Type) <> "none" Then
           doc.selection.Clear
        End If
        
        doc.selection.createRange.pasteHTML (html)
        
        
        Set doc = Nothing
        
    End Function
      

  27.   

    createRange是另外一种方法的,这个,我也是以前从msdn上找到的set ttt=document.getElementById("sele1")
     For i = 1To 50
            Set oOption = document.createElement("OPTION")
            oOption.Value = i
            oOption.text = i
            
            ttt.Add oOption
            Set oOption = Nothing
        Next
    <select id="sele1">
    </select>
    以前写的了
      

  28.   

    呵呵 你的用createRange的方法和我找的到的一样啊;只不过方法有些变化而已。最近在写用表格的一些操作 就是获得鼠标所在处的TD 这个如何获得阿?
    相关的例程是这样的;
    // 光标是否在表格中
    var selectedTD
    var selectedTR
    var selectedTBODY
    var selectedTable........function isCursorInTableCell() {
    if (eWebEditor.document.selection.type != "Control") {
    var elem = eWebEditor.document.selection.createRange().parentElement()
    while (elem.tagName.toUpperCase() != "TD" && elem.tagName.toUpperCase() != "TH"){ elem = elem.parentElement   <<----这里转化成VB程序后错误
    if (elem == null)
                    break
    }
    if (elem) {                        //这里什么意思啊?
    selectedTD = elem         
    selectedTR = selectedTD.parentElement
    selectedTBODY =  selectedTR.parentElement
    selectedTable = selectedTBODY.parentElement
    return true
    }
    }
    }*******************************
    * 请问各位大侠这里如何实现阿?*
    *******************************
      

  29.   

    关于dhtml在js和vbs是有很多不同的,一般msdn两种都有介绍的,你需要查一下,这个dhtml的,有很多细微的差别,我用的时候也是先查msdn的