高分!!谁能用VBA获得IE浏览器showModalDialog打开的模态窗口,对象 VBA HTMLDocument

time99901 2009-12-27 04:07:23
高分!!谁能用VBA获得IE浏览器showModalDialog打开的模态窗口,要获得VBA可以操作的对象(HTMLDocument)


Private Sub process(ByRef WB As WebBrowser)
Dim Doc As HTMLDocument
Dim Root As HTMLHtmlElement

Set Doc = WB.Document
Set Root = Doc.getElementsByTagName("html").Item

MsgBox Root.innerHTML


End Sub

Private Sub CommandButton1_Click()
Dim SW As New ShellWindows
Dim WB As WebBrowser

For Each WB In SW
If TypeOf WB.Document Is HTMLDocument Then
process WB
End If
Next

Set SW = Nothing
Set WB = Nothing

End Sub




上面是我写的代码。但是无法获得 弹出来的 ModalDialog 窗口
...全文
707 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
time99901 2009-12-28
  • 打赏
  • 举报
回复
没明白
time99901 2009-12-28
  • 打赏
  • 举报
回复
ding.................
whg01 2009-12-28
  • 打赏
  • 举报
回复
http://wenda.sogou.com/question/21955800.html 给分吧。
time99901 2009-12-28
  • 打赏
  • 举报
回复
【在线等】谁能用VBA获得IE浏览器showModalDialog打开的模态窗口
某Web应用系统,用showModalDialog弹出了一个表单
我想用VBA来读取excel中的数据自动填写到这个表单中。

谁能用VBA获得IE浏览器showModalDialog打开的模态窗口,要获得VBA可以操作的对象(HTMLDocument)

下面是我写的代码。可以对直接打开的popup.html操作
但是无法对用ModalDialog弹出来的窗口popup.html操作(找不到这个弹出窗口)

==VB=============================================================================

Public Sub process(ByRef WB As WebBrowser)
Dim Doc As HTMLDocument
Dim Root As HTMLHtmlElement

Set Doc = WB.Document
Set Root = Doc.getElementsByTagName("html").Item

Doc.getElementById("userId").setAttribute "value", ActiveSheet.Cells(ActiveCell.Row, 1)
Doc.getElementById("a").setAttribute "value", ActiveSheet.Cells(ActiveCell.Row, 2)
Doc.getElementById("b").setAttribute "value", ActiveSheet.Cells(ActiveCell.Row, 3)
Doc.getElementById("c").setAttribute "value", ActiveSheet.Cells(ActiveCell.Row, 4)
Doc.getElementById("d").setAttribute "value", ActiveSheet.Cells(ActiveCell.Row, 5)
Doc.getElementById("e").setAttribute "value", ActiveSheet.Cells(ActiveCell.Row, 6)
Doc.getElementById("f").setAttribute "value", ActiveSheet.Cells(ActiveCell.Row, 7)
Doc.getElementById("g").setAttribute "value", ActiveSheet.Cells(ActiveCell.Row, 8)
Doc.getElementById("h").setAttribute "value", ActiveSheet.Cells(ActiveCell.Row, 9)


'MsgBox ActiveCell.Value
'MsgBox ActiveSheet.Cells(ActiveCell.Row, ActiveCell.Column)
'MsgBox Root.innerHTML


End Sub

Public Sub fn1()
Dim SW As New ShellWindows
Dim WB As WebBrowser

For Each WB In SW
If TypeOf WB.Document Is HTMLDocument Then
If WB.Document.Title = "增加用户信息" Then
process WB
End If
End If
Next

Set SW = Nothing
Set WB = Nothing

End Sub


===index.html ===========================================================================

<html>
<head>
<title>操作</title>

<script language="javascript">

function OpenModalDialog(){
window.showModalDialog("popup.html",window);
}

</script>

</head>
<body>

<button>增加用户信息</button>

</body>
</html>

===popup.html ===========================================================================
<html>
<head>
<title>增加用户信息</title>

<script language="javascript">
var pWin = window.dialogArguments ? window : window.dialogArguments.window;
var pDoc = pWin.document;

</script>
</head>
<body>
<form method="POST" action="#">
身份代码:<input value="" name="userId" id="userId" ><br>
A:<input name="a" id="a"><br>
B:<input name="b" id="b"><br>
C:<input name="c" id="c"><br>
D:<input name="d" id="d"><br>
E:<input name="e" id="e"><br>
F:<input name="f" id="f"><br>
G:<input name="g" id="g"><br>
H:<input name="h" id="h"><br>
<input name="submit" id="submit" type="submit" value="提交"><br>
<form>
</body>
</html>
time99901 2009-12-28
  • 打赏
  • 举报
回复
ding~~~~~~~~~~~~~~`
time99901 2009-12-27
  • 打赏
  • 举报
回复
某Web应用系统,用showModalDialog弹出了一个表单
我想用VBA来读取excel中的数据自动填写到这个表单中。
time99901 2009-12-27
  • 打赏
  • 举报
回复
这个是 IE 的


<html>
<head>
<title></title>

<script language="javascript">
function fnOpenModal(){
window.showModalDialog("popup.html",window);
}
function fnOpenModeless(){
window.showModelessDialog("popup.html",window);
}
</script>

</head>
<body>
<button onclick="fnOpenModal()">fnOpenModal</button>
<button onclick="fnOpenModeless()">fnOpenModeless</button>
</body>
</html>


5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧