Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 8th, 2005, 10:58 AM
Authorized User
 
Join Date: Feb 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default Link workbook to DLL

Hi all,

I have previously posted a post about passing through a workbook name, and so link a VB6 DLL with a .xls workbook...

I'm stuck on the following: I want to make sure my DLL knows which workbook to work with, so I created this code in my DLL (I used project>references in both files):

Public Sub create(path_wkb)
Dim xlApp As Excel.Application
Dim xlWkbk As Workbook
Dim xlSheet As Worksheet
'
Set xlApp = New Excel.Application
Set xlWkbk = xlApp.Workbooks.Open(path_wkb)
'
set xlSheet = xlWkbk.Sheets("Sheet1")
xlsheet.range("A1").value = "test"
End Sub

However, I do not want to actually open the file, I just want to link xlWkbk to my workbook, but I did not find such a statement.

Any ideas would be much appreciated (Google wasn't able to help me today)

Max
 
Old August 9th, 2005, 04:01 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Max,

Not sure if this is in the right direction, but you can identify the links in a workbook by using the array of returned links within a workbook. You will then be able to identify the location of the said file.

    Dim myarray(1) As Variant
    myarray(0) = ActiveWorkbook.LinkSources(xlExcelLinks)
    MsgBox (myarray(0)(1))

Matt
 
Old August 9th, 2005, 05:26 AM
Authorized User
 
Join Date: Feb 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Matt,

I figured it out after some hours. It's actually dead simple

sub test(wrb)

dim xlWorkbook as object

''''code etc
Set xlWorkbook = GetObject(wrb) 'where wrb is path & filename
''''more code
end sub

link is set, so everything else is simple.





Similar Threads
Thread Thread Starter Forum Replies Last Post
convert unmanaged dll to managed dll nitesh kumar Visual C++ 2005 0 August 4th, 2008 04:53 AM
Install problems - VS 6.0 on XP SCRRUN.DLL PDM.DLL jeff4444 Visual C++ 0 December 6th, 2006 08:48 PM
The database dll crdb_oracle.dll could not be load Yeliz Crystal Reports 0 October 18th, 2006 08:12 AM
VB6 DLL linked to Excel workbook maxpotters Excel VBA 4 August 8th, 2005 08:15 AM
DLL & Excel - keep having to reset DLL reference! James Diamond Pro VB 6 2 May 25th, 2004 03:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.