Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Reference to other workbook problem

Thanks! It works now using the .References.AddFromfile construct

"Dick Kusleika" wrote in message ...
Terry

How is WBref dimmed? It appears that all your doing is creating another
Workbook variable that will be exactly the same as wb1. To add a reference
to another workbook, use code like this

Sub test()

Dim wb As Workbook

Set wb = Workbooks("book3.xls")

ThisWorkbook.VBProject.References.AddFromfile wb.FullName

End Sub

You can't use anything from book3.xls in the same module where this sub is
or you'll get a compile error - it won't know what those things are because
the reference hasn't been set. So this code will have to go in its own
module.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Terry Carpenter" wrote in message
...
Hello!,
I have two workbooks, wb1 and wb2, with macro code in them. wb2
has a hard reference to wb1 by selecting and setting a reference to
wb1 from the Tools menu in the IDE. This way, wb2 can access objects
such as a user-defined Public array of structs with code like this:

Project.UserDefinedType

Rather than hard coding the reference to wb1, I am trying to set it in
wb2 something like this:

Set WBref = Workbooks(wb1.Name)

This works but when I get to the code where it's supposed to access
the user-defined type, it doesn't see it. The code for this looks
like:

For i to Ubound(WBref.udt) to 0 Step -1

Where udt is supposed to be the user-defined Public array of structs.
The problem is WBref doesn't have any of the user-defined objects
available in the pull-down. Am I stuck with a hard reference to wb1?

Thanks!
Terry

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference macro in another workbook samuel Excel Discussion (Misc queries) 1 October 9th 08 06:26 PM
A reference problem - I THINK? Los Excel Discussion (Misc queries) 2 May 13th 08 07:20 PM
Reference workbook name Chris Excel Worksheet Functions 3 August 10th 06 03:57 PM
Reference problem jesmin Excel Discussion (Misc queries) 4 February 6th 06 02:08 PM
Problem with =sum(offset(cell reference,w,x,y,z). I want cell reference to be variable [email protected] Excel Worksheet Functions 2 December 11th 04 12:00 AM


All times are GMT +1. The time now is 03:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"