Openoffice BASIC甚至可以实现Web自动化吗?

问题描述

我正在尝试在OpenOffice中进行一些简单的网络抓取(我通常在Excel中工作,但是我试图将其移植给没有Excel的同事)。但是,当我尝试运行与此非常相似的内容时,它一直在给我这个BASIC运行时错误1。

error 1

这是相关的代码,我不确定该做些什么。

Sub Macro1
    Dim explorer As Object
    Set explorer = CreateObject("InternetExplorer.Application")
    explorer.Visible = True
    explorer.navigate("www.yahoo.com")
    
    Const READYSTATE_COMPLETE As Long = 4
    do while explorer.Busy Or explorer.readyState <> READYSTATE_COMPLETE
    Loop

    dim page as object
    set page = explorer.Document
    
    dim mailButton as object
    set mailButton = page.GetElementByID("ybar-navigation-item-mail") 'this is the line the error occurs on
    mailButton.Click
End Sub

解决方法

您知道您可以将脚本保存在vbs文件中(必须删除变量声明中的类型)并通过双击直接运行而不使用Office应用程序吗?我建议您使用这种方式。