0

我在电子表格中有一个人员列表和他们的电子邮件,我需要将他们的电子邮件输入到他们在 People Soft V8 上的帐户中。它们有数千个,所以我希望使这个过程自动化。

我从以下代码开始,但一直在

运行时错误
自动化错误 未指定错误

Sub GoToWebSiteUpdate()
Dim appIE As InternetExplorer
Dim sURL As String
Dim UserN As Variant
Dim myLoginID As String

Set appIE = New InternetExplorer
sURL = "Webaddress"
appIE.navigate sURL
appIE.Visible = True

     'Enter information in the first drop down
    Set UserN = appIE.document.getElementsById("InputBox")
    UserN(0).Value = "012354"


Set appIE = Nothing
End Sub

如果有人有任何想法会很棒,谢谢。

4

2 回答 2

2

有几种非常简单的方法可以做到这一点。

1)快速而肮脏的方法: 使用 Excel 公式(在每行的最后一个单元格中)将值连接在一起形成 SQL 语句(每行 1 个)。然后,您可以在您选择的 SQL 工具中运行它们。

2)“正确”的方法: 使用 ExcelToCI。这是一个 Excel 上传工具,它将运行所有页面验证等。它的内容比我在这里写的要多,但这是 PeopleBooks 中有关它的部分的链接:http: //docs.oracle.com/cd/ E28394_01/pt852pbh1/eng/psbooks/tcpi/book.htm?File=tcpi/htm/tcpi10.htm#H3002

亲切的问候

邓肯

于 2012-07-31T22:30:08.300 回答
0

我用来从 peoplesoft 提取报告的实际工作代码。代码是通过在互联网上查找各种博客和代码库来准备的

代码将循环遍历数据范围,即开始日期和结束日期并生成摘录。因为 Psoft 不能在提取中提供超过 65K 行,所以我让它一次运行 7 天。

Public Declare PtrSafe Function SetForegroundWindow Lib "user32" (ByVal HWND As Long) As Long

Sub PPS_Report_Extractor()

Dim Cell, Rng As Range   'Declaring cell for looping thru date range
'Dim appIE As Object      'InternetExplorer.Application
Dim appIE As InternetExplorer
Dim sURL As String       'URL String
Dim Element As Object    'HTMLButtonElement
Dim btnInput As Object   'MSHTML.HTMLInputElement
Dim ElementCol As Object 'MSHTML.IHTMLElementCollection
Dim Link As Object       'MSHTML.HTMLAnchorElement
Dim Counter, myNum       'Add Counter
    Counter = 0          'Declare Start for Counter
    myNum = 147          'Declare the number of repitition required

RemNamedRanges 'Delete the older ranges

'---Set New Range of reporting start dates -----
Range("A1").Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = "ElementCol"

Set Rng = Worksheets("Sheet1").Range("Elementcol")

'---Launch the IE -----
' Set appIE = CreateObject("InternetExplorer.Application")
Set appIE = New InternetExplorerMedium


sURL = "" ' open the URL by loggin intot PPS query then past that url here

appIE.Navigate sURL
appIE.Visible = True

'While appIE.Busy
'    DoEvents
'Wend

Pause (5) 'Allow IE to load

SendKeys "{ENTER}" 'Hit log on button in IE

'-Loop to generate the Files for full year starts here ---

For Each Cell In Rng

A = Format(Cell.Value, "DD-MM-YYYY")
B = Format(Cell.Offset(0, 1).Value, "DD-MM-YYYY")
'----Code for extraction ---START---

Application.Wait Now + TimeValue("00:00:5")
'Pause (5) 'Allow IE to load

appIE.Document.getelementbyid("InputKeys_bind2").Value = A
appIE.Document.getelementbyid("InputKeys_bind3").Value = B
appIE.Document.getelementbyid("#ICQryDownloadExcelFrmPrompt").Click

Pause (5)
SendKeys "{ENTER}", 5

'---Wait for excel generation to complete

I = 0
Set fo = CreateObject("Scripting.FileSystemObject")
Do Until fo.FileExists(OutFile) 'Loop until the output file is created, this could be infinity if there is a problem
    Application.Wait (Now + TimeValue("0:00:2")) 'Holds the program for 2 seconds
    DoEvents
    I = I + 1
    If (I = 10) Then
    SendKeys "%S" 'Alt S to save the report
    GoTo 1
    End If
Loop
1
'----Code for extraction ---END---
Next Cell

'-Loop to generate the Files for full year Ends here here ---

MsgBox "The range has " & K & " rows."


End Sub
于 2016-06-09T12:19:39.977 回答