如何使用Excel VBA自动化PeopleSoft?

时间:2012-07-31 15:11:40

标签: excel vba peoplesoft

我在电子表格中列出了人员及其电子邮件,我需要在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

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

2 个答案:

答案 0 :(得分: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

亲切的问候

邓肯

答案 1 :(得分: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