【问题标题】:how to use CreateObject in excel vba?如何在 excel vba 中使用 CreateObject?
【发布时间】:2013-08-17 10:02:17
【问题描述】:
Public Sub InformationManagement(myTable As String)
    Dim myaccess As Object
    Dim mydata As String
    mydata = ThisWorkbook.Path & "\Management.mdb"
    Set myaccess = CreateObject(mydata)
    With myaccess
        .Visible = True
        .DoCmd.OpenTable myTable
        .DoCmd.Maximize
    End With
    Set myaccess = Nothing
End Sub

Row -> Set myaccess = CreateObject(mydata) 出现消息错误“Run-time error '429' ActiveX component can't create object”

有谁知道如何解决这个问题?非常感谢

【问题讨论】:

  • 你的目的似乎是打开一个数据库连接。如果是这样,你应该使用ADODB.Connection object
  • 请解释您要做什么。

标签: excel vba


【解决方案1】:

我已经有一段时间没有这样做了,但我想它应该更像......

Dim mydata As String
Dim myaccess As Object

mydata = ThisWorkbook.Path & "\Management.mdb"
Set myaccess = CreateObject("Access.Application")
With AccDatabase

    .OpenCurrentDatabase mydata 
    .DoCmd.OpenTable myTable
    .DoCmd.Maximize
End With
Set myaccess = Nothing

【讨论】:

    猜你喜欢
    • 2017-10-14
    • 2010-09-15
    • 1970-01-01
    • 2018-10-27
    • 1970-01-01
    • 2017-04-24
    • 2021-01-03
    • 2012-05-15
    • 1970-01-01
    相关资源
    最近更新 更多