Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to open a workbook programmatically. I get the name of the
workbook from the listbox value generated by the optButton click event. That is working fine. But I get an error on the line workbooks.open fname I suspect it has something to do with the chdir cmd and the path to the workbooks - I don't think I am giving vba enough info to find the file, but I don't know what to do to fix it. Could you please review this code and point out my error? I am doing the chdir in the optButton click event because the directory will be different depending on which optButton is clicked. So I am: filling the list box changing the directory getting the name of the workbook trying to open the workbook - here is where my failure is. ' Fill the list box Private Sub obHouse_Click() Dim SrcData As Range Dim cCell As Range Set SrcData = Range("rngHouse2") With lbVendor .Clear For Each cCell In SrcData.Cells .AddItem cCell.Value Next cCell ' change to the correct sub-directory ChDir "C:\Pricing\House" End With End Sub ' Open the workbook Public Sub lbVendor_Click() Dim fname As String With lbVendor fname = .List(.ListIndex) ' capture the value of the list index# selected Debug.Print fname End With Workbooks.Open fname fname = "" 'clears fname in case they choose another opt button Debug.Print fname End Sub Thank you muchly for your time and expertise Joanne |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2007 - error saving file & error loading dll | Excel Discussion (Misc queries) | |||
error - unreadable content in pivot table file - how do I find it | Excel Worksheet Functions | |||
Cannot find file - code error | Excel Programming | |||
Automation Error: The system cannot find file specified | Excel Programming | |||
How do I find a file/spreadsheet that Excel says is Already open but I can't find it? | Excel Discussion (Misc queries) |