我正在制作一个工作工具,在我们的sharepoint上生成一个新的项目项目。
在sharepoint上,我们有一个需要填写的表单,并确定我使用IE.Document.All.Item("id").value=value
命令的表单的文本字段。
它在一个单独的vbs文件中工作,但是当我尝试从hta启动它时,它会阻塞IE.Documents.All.item
命令。有谁知道如何解决这个问题?
代码如下所示(语言:vbscript):
Sub SendProjectData
Set IE = CreateObject("InternetExplorer.Application")
set WshShell = CreateObject("WScript.Shell")
IE.Navigate "https://sharepointpage"
IE.Visible = true
sleep1 6000 'external defined sleep command'
IE.Document.All.Item("projectid").Value = "projectname"
WshShell.AppActivate "IE"
WshShell.SendKeys "{ENTER}"
End Sub
答案 0 :(得分:0)
oIe.document.getElementById("testMsgBox").value = "hallo"
或
oIE.document.all.testMsgBox.value = "hallo"
也许这有帮助,莱因哈德
答案 1 :(得分:0)
这应该有效。使用IE11在Win10下测试:
首先是HTML测试文件:
<html>
<head><title>MyInputFile</title></head>
<body>
<h1>IE with Input field</h1>
<input type="text" id="myText" value="Default text" size="20">
</body>
</html>
现在HTA文件填写html文件:
<html>
<head>
<title>Hypertext-Application Demo</title>
<HTA:APPLICATION ID="oHTA">
<script language="vbscript">
sub Window_Onload
self.resizeto 500,200
self.MoveTo 50,50
End Sub
Sub fillHta()
myText.value = "New Text"
End Sub
Sub startAndFill()
set wsh = CreateObject("WScript.Shell")
'Set oIE = CreateObject("InternetExplorer.Application")
Set oIE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
oIE.Navigate "d:\MyInputFile.html"
oIE.Visible = true
Do: Loop Until oIE.Busy = False
Do: Loop Until oIE.Document.ReadyState = "complete"
oIe.document.getElementById("myText").value = "New Text" 'use this
x = oIe.document.getElementById("myText").value
oIE.document.all.myText.value = x & "; New Text2" 'or this
End Sub
</script>
</head>
<body bgcolor="#99CCFF">
<p>Simple Demo of Hypertext Applikationen</p>
<input type="button" value="Fill HTA input field" onclick="fillHta()">
<input type="text" id="myText" value="Default text" size="20">
<p><input type="button" value="start and fill IE field" onclick="startAndFill()"> D:\MyInputFile.html</p>
</body>
</html>
享受,莱因哈德