1

在 Excel 中使用 HypConnect 时,它会自动激活与运行宏时恰好位于的工作表的连接。但是,如果您从 Smart View 面板中选择连接,它会连接到应用程序/数据库,但不会在任何工作表上激活它。

我有一个使用与多个应用程序/数据库的连接的报告。不幸的是,第一个 HypConnect 将该应用程序/数据库激活到当前工作表,然后忽略剩余的连接请求。我只需要它连接到应用程序/数据库,然后宏的其余部分负责根据需要刷新工作表。如果我在运行之前手动连接到每个应用程序/数据库,宏的其余部分就可以工作。

我在 64 位 Windows 10 企业版 (v10.0.17763) 上运行 64 位 Microsoft Office 365 Excel 版本 1910 (Build 12130.20390)。SmartView 是版本 11.1.2.5.710(内部版本 127),Essbase 是 11.1.2.3.508

这是我尝试使用的代码示例:

Public Declare PtrSafe Function HypConnect Lib "HsAddin" (ByVal vtSheetName As Variant, ByVal vtUserName As Variant, ByVal vtPassword As Variant, ByVal vtFriendlyName As Variant) As Long
Public Declare PtrSafe Function HypDisconnectAll Lib "HsAddin" () As Long
Public Declare PtrSafe Function HypMenuVRefreshAll Lib "HsAddin" () As Long
Sub RunAllFreaks()


x = HypConnect("Empty", "UserName", "Password", "EssbaseCluster-p_FXAPAC_FXAPAC")
x = HypConnect("Empty", "UserName", "Password", "EssbaseCluster-qa_FXAPAC_FXAPAC")
x = HypConnect("Empty", "UserName", "Password", "EssbaseCluster-p_FXEMLA_FXEMLA")
x = HypConnect("Empty", "UserName", "Password", "EssbaseCluster-qa_FXEMLA_FXEMLA")
x = HypConnect("Empty", "UserName", "Password", "EssbaseCluster-p_FXGP_FXGP")
x = HypConnect("Empty", "UserName", "Password", "EssbaseCluster-qa_FXGP_FXGP")
x = HypConnect("Empty", "UserName", "Password", "EssbaseCluster-p_FXNA_FXNA")
x = HypConnect("Empty", "UserName", "Password", "EssbaseCluster-qa_FXNA_FXNA")

Worksheets("Setup Recon Tabs").Range("Recon1_App1_Connection").Value = "EssbaseCluster-p_FXAPAC_FXAPAC"
Worksheets("Setup Recon Tabs").Range("Recon1_App2_Connection").Value = "EssbaseCluster-qa_FXAPAC_FXAPAC"
Worksheets("Setup Recon Tabs").Range("Recon2_App1_Connection").Value = "EssbaseCluster-p_FXAPAC_FXAPAC"
Worksheets("Setup Recon Tabs").Range("Recon2_App2_Connection").Value = "EssbaseCluster-qa_FXAPAC_FXAPAC"
Worksheets("Setup Recon Tabs").Range("Recon4_App1_Connection").Value = "EssbaseCluster-p_FXAPAC_FXAPAC"
Worksheets("Setup Recon Tabs").Range("Recon4_App2_Connection").Value = "EssbaseCluster-qa_FXAPAC_FXAPAC"

Worksheets("Entity").Range("PARAM_StartIndex").Value = 1
Worksheets("Entity").Range("PARAM_EndIndex").Value = 8

RefreshDataAll

Worksheets("Setup Recon Tabs").Range("Recon1_App1_Connection").Value = "EssbaseCluster-p_FXEMLA_FXEMLA"
Worksheets("Setup Recon Tabs").Range("Recon1_App2_Connection").Value = "EssbaseCluster-qa_FXEMLA_FXEMLA"
Worksheets("Setup Recon Tabs").Range("Recon2_App1_Connection").Value = "EssbaseCluster-p_FXEMLA_FXEMLA"
Worksheets("Setup Recon Tabs").Range("Recon2_App2_Connection").Value = "EssbaseCluster-qa_FXEMLA_FXEMLA"
Worksheets("Setup Recon Tabs").Range("Recon4_App1_Connection").Value = "EssbaseCluster-p_FXEMLA_FXEMLA"
Worksheets("Setup Recon Tabs").Range("Recon4_App2_Connection").Value = "EssbaseCluster-qa_FXEMLA_FXEMLA"

Worksheets("Entity").Range("PARAM_StartIndex").Value = 9
Worksheets("Entity").Range("PARAM_EndIndex").Value = 16

RefreshDataAll
4

0 回答 0