【问题标题】:Copying Excel data to Oracle Applications form将 Excel 数据复制到 Oracle Applications 表单
【发布时间】:2018-08-14 13:58:17
【问题描述】:

我不熟悉使用 VBA 或其他任何方式将 Excel 数据移动到外部程序。我做了一些研究,但我找不到任何真正的答案来解决我正在尝试做的事情。

在 Excel 工作表上,我有多个(从 1 到 1,000 行)从第 84 行开始的测量信息:姓氏、名字、性别、身高、体重等。我需要在Oracle 应用程序表单。

这是我创建的代码,它可以完成这项工作,但它只会处理第一行。除了测量行之外,还必须处理初始数据行。我在代码中添加了换行符,以尝试显示 Oracle 表单中每一行的布局位置。此外,每一行都以不同的数字开头。它从 10 开始,以 10 为增量增加。

一长串制表符对于访问表单中的另一组列是必需的。如果您手动执行此操作,您将使用下拉菜单,但我认为这在 VBA 中是不可能的。可能吗?还是使用 VBA 以外的其他方式来执行此操作会更好?

Sub MoveToOracle()
    AppActivate "Oracle Applications - cbsProd (11.5.10.2)"
    Application.Wait (Now + TimeValue("0:00:01"))

    SendKeys ("10")
    SendKeys ("{TAB}")
    SendKeys ("A")
    SendKeys ("{TAB}")
    SendKeys Range("E1")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("ENV")
    SendKeys ("{DOWN}")

    SendKeys ("20")
    SendKeys ("{TAB}")
    SendKeys ("1")
    SendKeys ("{TAB}")
    SendKeys ("FN{F3}")
    SendKeys ("{TAB}")
    SendKeys Range("A2")
    SendKeys ("{TAB}")
    SendKeys Range("B2")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys ("{TAB}")
    SendKeys Range("C2")
    SendKeys ("{TAB}")
    SendKeys Range("D2")
    SendKeys ("{TAB}")
    SendKeys Range("E2")
    SendKeys ("{TAB}")
    SendKeys Range("F2")
    SendKeys ("{TAB}")
    SendKeys Range("G2")
End Sub

编辑:不会从 Excel 工作簿中读取读取顺序号。每个新行都需要以 10 为增量的唯一数字开头,从 10 开始。我不确定如何使用 SendKeys 循环遍历 Excel 数据。

另外,我几乎无法使用 Excel。我没有创建或管理数据库的开发权限。

【问题讨论】:

  • oracle表单后面有数据库吗?是否可以通过导出/导入将信息导入数据库,然后从其数据库中填写表格?通过 VBA 将数据“手动”写入 oracle 表单对我来说似乎有点过于复杂。
  • 有,但我无法访问它。用 VBA 以外的东西做我想做的事情是否可能/更好?
  • 这取决于.. 你到底想做什么?将数据写入该表单后会发生什么?
  • 我在 Excel 工作表上有一个排序表。我需要这些数据以这种 Oracle 形式结束。我发布的图像是代码的结果。
  • 这就是最终目标?只是表格中的数据?不是以某种形式保存的(例如 oracle db)?

标签: oracle vba excel


【解决方案1】:

据我所知,没有用于 VBA 的公共 API 可用于与 oracle 表单交互,因此您最好的选择可能是这种方式。

编辑:

要遍历您的工作表,您需要创建某种counter 和/或loop

编辑:

或者,您可以为此创建一个临时数据库。将 Excel 工作表中的数据导出到该临时数据库,然后从中读取数据。 excel内置了导出功能,表单应该很容易填写,后面有oracle数据库。

【讨论】:

  • 好的,但是我需要遍历行并增加读取订单号,我不确定如何使用 SendKeys 来做到这一点。
  • 您能否仅在表单内使用键盘增加读取的订单号?
  • 我想没关系。还能怎么办?
  • 在我的回答中添加了另一个建议。
  • 我无法创建临时数据库。
【解决方案2】:
    Sub MoveToOracle()
    '   Oracle Applications Forms is a java VM window
    '   VBA code interaction with Controls within the VM window is by the use of sendkeys
    '   One commercial alternate application is Data Load.
    '
    AppActivate "Oracle Applications - cbsProd (11.5.10.2)"
    '   API SetForegroundWindow preferred over AppActivate
    Text string for 1 st row in Oracle Applications
    Let  Field_Text = "10" & "{TAB}" & "A" & "{TAB}" & Range("E1").Value & "{TAB}" & "{TAB}" & "{TAB}" & "ENV" & "{DOWN}"
    '   When using sendkeys the NUMLOCK is toggled on / off with each call of SendKeys
    '   NUMLOCK ON
    Let  SendKeysString = Field_Text & "{NUMLOCK}"
    SendKeys Field_Text
    '   Preferred dedicated pause sub using API sleep
    '   Author Kevin zorvek Posted on 2007-06-22 http://www.experts-exchange.com/
    '   Pause 0.6 seconds here for Oracle Applications before continuing
    '   Allows for Oracle Applications to catch up
    '   NUMLOCK ON
    '   Place pause code here
    Let  SendKeysString = vbNullString
    AppActivate "Oracle Applications - cbsProd (11.5.10.2)"
    '   Text string for 2 nd row in Oracle Applications
    Let  Field_Text = ""     ' Empty variable
    Let  Field_Text = "20" & "{TAB}" & "1" & "{TAB}" & "FN{F3}" & "{TAB}" & Range("A2").Value & "{TAB}" & Range("B2").Value
    Let  Field_Text = Field_Text & "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}"
    Let  Field_Text = Field_Text & Range("C2").Value & "{TAB}" & Range("D2").Value & "{TAB}" & Range("E2").Value & "{TAB}" & Range("F2").Value & "{TAB}" & Range("F2").Value
    Let  Field_Text = Field_Text & "{NUMLOCK}"
    SendKeys Field_Text
    '   Pause 0.6 seconds here for Oracle Applications before continuing
    '   Allows for Oracle Applications to catch up
    '   NUMLOCK ON
    '   Place pause code here
    Let SendKeysString = vbNullString
End Sub

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-13
  • 1970-01-01
  • 1970-01-01
  • 2021-11-01
  • 1970-01-01
  • 2017-09-24
相关资源
最近更新 更多