oracle - 多个 Oracle Smartview 刷新不在循环中工作(当我单步执行代码时有效)

标签 oracle excel hyperion smartview vba

我有以下代码,当我逐行单步执行时(或者即使我只单步执行 1 或 2 次循环迭代然后触发其余部分),它的工作原理就像一个魅力。当我从一个按钮运行它时,代码不起作用,因为 Hyperion Retrieve 永远不会针对我更改的部门的每次迭代进行更新。部门本身已正确更改(从 Excel 和生成的 PDF 文件中可以看出)。

因此,简而言之,代码工作时没有发现或捕获错误,但结果是一组具有相同数据的 PDF,尽管在按下按钮运行时标有不同的部门。

我已经在网上搜索了很多,尝试使用 DoEventsApplication.Wait没有成功。有没有人知道如何确保在按下按钮运行时每次循环迭代都会发生刷新?

Option Explicit

Declare Function HypMenuVRefresh Lib "HsAddin.dll" () As Long

Sub CreateAllPDFS()

'... setup code to declare variables and loop range ...


'loop through departments
Dim cel As Range
For Each cel In rngLoop 'rngLoop declared and set in setup code

    'set department on drivers tab
    wsDrivers.Range("B4").Value = "'" & cel.Value

    '*** --> tried to wait before the loop (just shot in the dark type thing)
    'Application.Wait (Now + TimeValue("00:00:02")) 'pauses for 10 seconds, adjust as needed

    'refresh hyperion
    Dim lngReturn As Long
    lngReturn = HypMenuVRefresh()

    ' *** --> tried Do Events
    'DoEvents
    '*** --> tried to wait after the loop
    'Application.Wait (Now + TimeValue("00:00:02")) 'pauses for 10 seconds, adjust as needed

        'quick error check
        If lngReturn <> 0 Then
            MsgBox "Could Not Refresh!"
            Exit Sub
        End If

    'save as pdf
    wsPL.ExportAsFixedFormat xlTypePDF, cel.Offset(, 1) & "\" & cel.Offset(, 2) & ".pdf", , , , , , False

Next

End Sub

最佳答案

我们引用 HypMenuVReresh 的在线文档据说

HypMenuVRefresh() retrieves data into the active sheet, and places the data at the beginning of the active worksheet.



来源:https://docs.oracle.com/cd/E12032_01/doc/epm.921/html_hsv_user/hsv_help-13-63.htm#528899

因此,通过在执行 wsPL.Activate 之前激活目标工作表(即在本例中为 HypMenuVReresh)找到解决方案.

因此,一般来说,最好总是在 HypMenuVRefresh 之前激活目标工作表。因为HypMenuVRefresh如果它正在刷新未连接到 Hyperion 多维数据集的工作表,则不会引发错误。此外,HypConnected()可以声明在刷新之前检查工作表是否连接到 Hyperion 立方体(即 Hyperion 可刷新)。

HypConnected() returns a true value if the sheet is connected to an provider and returns a false value if the sheet is not connected.

关于oracle - 多个 Oracle Smartview 刷新不在循环中工作(当我单步执行代码时有效),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39458689/

相关文章:

sql - 使用映射表更改大量记录键

python - 使用python从CSV插入到oracle表中

php - 当我尝试在 yii 框架中执行查询时连接被重置

vba - 遍历所有工作表以分别在每个选项卡中查找最底部的数据行

vba - 将数据复制到 Excel 中另一个工作表上的特定单元格区域

excel - 使用 VBA 自动智能 View hyperion 刷新

excel - 在 Smart View for Oracle 中创建 VBA 刷新宏

oracle - 如何访问结构并获取列列表,refcursor 的数据类型?

Excel VBA : Unexpected result with Range and Cells

vba - 使用 excel vba 打开特定版本的 brio(hyperion 报告工作室)