Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
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 February 28th, 2006, 06:58 AM
Authorized User
 
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default ListFillRange from another closed workbook

How do I create a drop down list from another excel workbook without opening it?

With Worksheets(1)
    Set lb = .Shapes.AddFormControl(xlListBox, 100, 10, 100, 100)
        lb.ControlFormat.ListFillRange = Workbooks("Ports and Agents.xls").Worksheets("Ports and Agents").Range("a1:a500").Address(external:=True)

End With

doesnt work. I would really appreciate some help.

Thanks

 
Old March 1st, 2006, 02:54 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

I think you can use Office automation like this:

Sub OpenAnotherExcel()

Dim xlApp As Excel.Application
Set xlApp = New Excel.Application

xlApp.Workbooks.Open ("Ports and Agents.xls")

Set lb = .Shapes.AddFormControl(xlListBox, 100, 10, 100, 100)

lb.ControlFormat.ListFillRange = xlApp.Workbooks("Ports and Agents.xls").Worksheets("Ports and Agents").Range("a1:a500").Address(external:=True)

xlApp.ActiveWorkbook.Close False
xlApp.Quit
se xlApp = Nothing


End Sub


-vemaju





Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I call a sub in a different workbook? TomW Excel VBA 1 April 12th, 2007 10:34 AM
Workbook Open anup.bihani Excel VBA 2 November 30th, 2006 01:05 AM
Inactive Workbook halem2 Beginning VB 6 0 June 8th, 2006 04:42 PM
workbook problem sham Excel VBA 4 March 15th, 2005 08:03 AM
workbook not found! timoma Access VBA 2 January 17th, 2005 08:47 PM





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