OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 26-02-2015, 21:49
ager ager is offline
Member
 
Join Date: Jul 2010
Location: Russia
Posts: 44
Default References...

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:
Code:
ThisWorkbook.VBProject.References.AddFromFile "FileName"
What is corresponding function in CorelDRAW X4?
Reply With Quote
  #2  
Old 26-02-2015, 22:39
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,778
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default 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:
Code:
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;"
        .Open
    End With
    
    If objConn.State = 1 Then
        MsgBox "The connection to this database is working!", vbInformation
    Else
        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")
        objRS.MoveNext
    Wend
    
    objRS.Close
    objConn.Close

    Set objRS = Nothing
    Set objConn = Nothing
End Sub
Hopefully that will be helpful,

-Shelby
Reply With Quote
  #3  
Old 26-02-2015, 23:09
ager ager is offline
Member
 
Join Date: Jul 2010
Location: Russia
Posts: 44
Default

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


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fix Object References in macros JavierDiaz Macros/Add-ons 2 19-12-2005 07:32


All times are GMT -5. The time now is 11:12.


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