OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   References... (http://forum.oberonplace.com/showthread.php?t=24720)

ager 26-02-2015 21:49

How to add a new reference in macro from Tools>References> (in VB-editor) using programm code?
For example, I want to use msdao15.dll from "common files\system\ado"
There is simple function in VBA-Excel:

ThisWorkbook.VBProject.References.AddFromFile "FileName"
What is corresponding function in CorelDRAW X4?

shelbym 26-02-2015 22:39

Late Binding
As far as I know there is not such a function. So if you do not want to add the reference you will need to use Late Binding. Here is a simple example:

Sub LateBindingExample()
    Dim objConn As Object, objRS As Object
    Set objConn = CreateObject("ADODB.Connection")
    Set objRS = CreateObject("ADODB.Recordset")
    With objConn
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .ConnectionString = "Data Source=C:\Temp\sample.MDB;"
    End With
    If objConn.State = 1 Then
        MsgBox "The connection to this database is working!", vbInformation
        MsgBox "You were unable to connect to the database!", vbInformation
    End If
    objRS.Open "Select Price FROM tblPrices", objConn
    While Not objRS.EOF
        MsgBox objRS("Price")

    Set objRS = Nothing
    Set objConn = Nothing
End Sub

Hopefully that will be helpful,


ager 26-02-2015 23:09

Thank you, Shelby, for the explanation!
Late Binding works as well as adding the reference.

All times are GMT -5. The time now is 03:17.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com