【发布时间】:2013-11-13 21:20:09
【问题描述】:
首先,我是 iMacros 的新手,对 VBA 不太熟悉(我知道这不是一个好的开始) 所以我的最终游戏是使用 iMacros 访问一个站点,在站点上填写一个表格,其中包含访问表中的名称输入名称并从该站点获取一些结果文本,获取文本并将其放在表中。我必须为表中的每条记录执行此操作。到目前为止,这就是我所拥有的:
Dim Rs As DAO.Recordset 'recordset for list of names from VcWAuditUsers
Dim db As DAO.Database
Dim SQL As String
Dim Sql2 As String
Dim STRErr As String
Dim sTableName As String
Dim serverName As String
Dim dbName As String
Dim strUserCnt As Integer
Dim UserName As Variant
Dim StrSql As String
Dim iim1, iret
Set iim1 = CreateObject("imacros")
iret = iim1.iimInit
iret = iim1.iimPlayCode("URL GOTO=https://www.sam.gov/portal/public/SAM/)
sTableName = "vCPpAuditUsers"
serverName = GetLinkedServer(sTableName)
dbName = GetLinkedDatabase(sTableName)
SQL = "Select Distinct FName, LName from " & sTableName
Set db = CurrentDb
Set Rs = db.OpenRecordset(SQL)
If (Not Rs.EOF And Not Rs.BOF) Then
Rs.MoveLast
Rs.MoveFirst
With Rs
Do While (Rs.EOF = False)
UserName = Trim(![FName]) & " " & Trim(![LName])
MsgBox ("New Name: " & UserName)
strUserCnt = Rs.recordCount
MsgBox ("Number of rows: " & strUserCnt)
'set iMacros variables
iret = iim1.iimSet("CONTENT", UserName)
iret = iim1.iimPlay("Y:\Data\FS01-M\Healthcare\SAM_iMacro\SAMiMacro.iim")
If iret < 0 Then
MsgBox iim1.iimGetLastError()
End If
StrSql = "Insert Into ExceptionResults Values('" & UserName & "','" & iim1.iimGetExtract(1) & Now & "')"
MsgBox ("Test SqlInsert: " & StrSql)
.MoveNext
Loop
End With
Rs.Close
db.Close
End If
我知道我遗漏了一些关键的东西,但我一直无法找到一个很好的例子来作为我正在做的事情的基础。
非常感谢任何帮助!
谢谢。
【问题讨论】:
-
请详细说明您面临的具体问题。
-
我已经弄清楚我想要做什么。如果有人好奇,这是我的最终结果:
-
很抱歉。我不确定如何让 iim 使用 VBA 代码。下面是我的解决方案。我在 .iim 部分中遗漏了一些代码使用了变量 {{USERNAME}} 然后能够将该数据传回。