How do you programmatically load references?

How do you programmatically load references?

Anonymous
Not applicable
690 Views
2 Replies
Message 1 of 3

How do you programmatically load references?

Anonymous
Not applicable
I have several large VBA programs that I've written in the AutoCAD VBA IDE. These programs retrieve data from Excel files. Most of the time, the programs work fine. However, occasionally, I need to send the program to a new user that uses a different version of Excel. Of course, the program doesn't work in these cases, because the Excel reference is wrong, and it is sometimes difficult to explain to the user how to go into the VBA interface and change the reference.
I need to find a way to programmatically set the Excel library reference. Ideally, this code would search the users computer for the version of excel, and then load the correct VBA reference.

I've done some research, and found different methods for loading the references between other Microsoft programs, but not between Acad and Excel.

I'm hoping someone here can provide some direction.


Thanks
0 Likes
691 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
i have the same problem like yours, untill i use Access library, all de code run smoothly,and Excel can change to Access as well
0 Likes
Message 3 of 3

Anonymous
Not applicable
Hi,

Here are a couple of methods taken from Randal Rath's newsletter of 2
Nov 2000

Question

What in your opinion is the best way to check to see if a file exists in a folder

The Common Answer:
{code}
Private Function DoesFileExist(strFnamePath As String) As Boolean
strFnamePath = Dir(strFnamePath)
If strFnamePath = "" Then
DoesFileExist = False
Else
DoesFileExist = True
End If
End Function
{code}


The Secret Answer:

{code}
Declare Function PathFileExists Lib "shlwapi" Alias _
"PathFileExistsA" (ByVal strFile As String) As Long

Public Function FileExists(spFileSpec As String) As Boolean
FileExists = PathFileExists(spFileSpec)
End Function ' FileExists
{code}


Is it better? You bet! It handles any path (UNC or Local) and is about 200% faster!


Regards,


Laurie Comerford

bmincemoyer@verizon.net wrote:
> I have several large VBA programs that I've written in the AutoCAD VBA IDE. These programs retrieve data from Excel files. Most of the time, the programs work fine. However, occasionally, I need to send the program to a new user that uses a different version of Excel. Of course, the program doesn't work in these cases, because the Excel reference is wrong, and it is sometimes difficult to explain to the user how to go into the VBA interface and change the reference.
> I need to find a way to programmatically set the Excel library reference. Ideally, this code would search the users computer for the version of excel, and then load the correct VBA reference.
>
> I've done some research, and found different methods for loading the references between other Microsoft programs, but not between Acad and Excel.
>
> I'm hoping someone here can provide some direction.
>
>
> Thanks
>
0 Likes