Ms access 向帧内的字段添加值
'这是检查原始链接是否导致登录页面,如果是,则登录,否则其重定向Ms access 向帧内的字段添加值,ms-access,vba,Ms Access,Vba,'这是检查原始链接是否导致登录页面,如果是,则登录,否则其重定向 Dim IE As InternetExplorer Set IE = New InternetExplorer Dim hDocument As MSHTML.HTMLDocument Dim hElementCollection As MSHTML.IHTMLElementCollection Dim hInputElement As MSHTML.htmlInputElement
Dim IE As InternetExplorer
Set IE = New InternetExplorer
Dim hDocument As MSHTML.HTMLDocument
Dim hElementCollection As MSHTML.IHTMLElementCollection
Dim hInputElement As MSHTML.htmlInputElement
IE.Visible = True
Dim url As String
url = "www.blah.com"
IE.Navigate url
Call SleepIE(IE)
PauseApp 3
Dim xSom, xFrame As Object
我也试过了
Set hElementCollection = IE.Document.frames("mainFrameSet").Document.frames("dataFrame").Document.frames("dataFrameSet").Document.frames("workspaceFrameSet").Document.all
For Each hInputElement In hElementCollection
If hInputElement.getAttribute("id") = "ListingURE_searchText" Then
hInputElement.Value = "555"
End If
Next hInputElement
blow是PageSource的短版本,长20页
Set hElementCollection = hDocument.getElementsByTagName("INPUT")
For Each hInputElement In hElementCollection
If hInputElement.getAttribute("id")
hInputElement.Value = "test"
End If
Next hInputElement
您所使用的看起来更像oldskool VBscript。你真的不应该用那个
下面是一个如何将getElementById与JavaScript一起使用以设置文本框值的示例:
<head>
<frameset id="mainFrameSet" rows="*">
<frame id="headerPlusFrame" scrolling="no" marginwidth="0" marginheight="0" src="../listing
<iframe id="dataFrame"
<html>
<head>
<frameset id="dataFrameSet" rows="*,20">
<frameset id="centerFrameset" cols="*,0">
<frame id="workspaceFrame" frameborder="0" border="0" framespacing="2" title="Workspace" src="workspace.do" name="workspaceFrame">
<html>
<head>
<frameset id="workspaceFrameSet" class="panelFrame" border="0" framespacing="0" frameborder="0" rows="18,*">
<frame id="workspaceHeaderFrame" scrolling="no" noresize="" marginwidth="0" marginheight="0" src="workspaceHeader.do?title=" title="Workspace Header" name="workspaceHeaderFrame">
<frame id="workspaceBodyFrame" noresize=""
<html>
<head>
<body onresize="resizeUreWithTimeout()" onload="onLoad()">
<form id="listingForm"
<table id="ListingURE" cellspacing="0" cellpadding="1" style="width: 1249px; height: 376px;">
<script type="text/javascript">
<tbody>
<tr>
<td valign="top">
<table id="ListingURE_toolbar0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<script type="text/javascript">
<td>
<script type="text/javascript">
<div id="ListingURE_toolbar0Container"
<table cellspacing="0" cellpadding="0">
<tbody>
<tr valign="middle">
<td>
<input id="**ListingURE_searchText**" class="textinputs" type="text" value="" name="ListingURE_searchText" onselectstart="ev
函数fnSetValue(){
document.getElementById('ListingURE_searchText')。值='testing 123';
}
您的HTML非常混乱。我想你最好先把它修好。此外,你的问题完全不清楚。你用什么做什么。你试过什么?考虑提供更多这些细节。我不能粘贴20页的HTML,所以我只是粘贴了我认为重要的内容,我对HTML一无所知,所以如果我需要添加更多内容,请告诉我。我尝试使用ie.document.getElementById和getElementsByTagName来设置该字段的.value,但是运气不好,我试图在文档的下面做一些事情。getElementById(“ListingURE_searchText”)。value=“abc”我上面的代码在没有框架的站点上工作,所以我认为我的问题与框架有关。我也尝试了下面的内容,但没有成功,即Document.frames(“mainFrameSet”).Document.frames(“dataframes”).Document.frames(“dataFrameSet”).Document.frames(“workspaceFrameSet”).Document.getElementByID(“ListingURE_searchText”).value=“testing”搜索“框架间的脚本通信”。这是可以做到的,但相当棘手。为什么你需要这些框架呢?我需要从我们的网站上收集一些信息,所以我必须进入所有框架的页面
<head>
<frameset id="mainFrameSet" rows="*">
<frame id="headerPlusFrame" scrolling="no" marginwidth="0" marginheight="0" src="../listing
<iframe id="dataFrame"
<html>
<head>
<frameset id="dataFrameSet" rows="*,20">
<frameset id="centerFrameset" cols="*,0">
<frame id="workspaceFrame" frameborder="0" border="0" framespacing="2" title="Workspace" src="workspace.do" name="workspaceFrame">
<html>
<head>
<frameset id="workspaceFrameSet" class="panelFrame" border="0" framespacing="0" frameborder="0" rows="18,*">
<frame id="workspaceHeaderFrame" scrolling="no" noresize="" marginwidth="0" marginheight="0" src="workspaceHeader.do?title=" title="Workspace Header" name="workspaceHeaderFrame">
<frame id="workspaceBodyFrame" noresize=""
<html>
<head>
<body onresize="resizeUreWithTimeout()" onload="onLoad()">
<form id="listingForm"
<table id="ListingURE" cellspacing="0" cellpadding="1" style="width: 1249px; height: 376px;">
<script type="text/javascript">
<tbody>
<tr>
<td valign="top">
<table id="ListingURE_toolbar0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<script type="text/javascript">
<td>
<script type="text/javascript">
<div id="ListingURE_toolbar0Container"
<table cellspacing="0" cellpadding="0">
<tbody>
<tr valign="middle">
<td>
<input id="**ListingURE_searchText**" class="textinputs" type="text" value="" name="ListingURE_searchText" onselectstart="ev
<div>
<input type="text" id="ListingURE_searchText" />
<input type="button" onclick="fnSetValue()" title="Set value" />
</div>
<script language="javascript" type="text/javascript">
function fnSetValue() {
document.getElementById('ListingURE_searchText').value = 'testing 123';
}
</script>