PDA

View Full Version : [SOLVED:] Open a workbook without knowing it's name.



TButhe
04-04-2005, 12:21 PM
Here's what I would like to do -
I have an old version of a form and I need to create a button on my new form that would open a dialog box and allow the user to browse to their workbook and open it. Then I will copy the data from the old workbook and paste it to the new one. The copying and pasting I can handle, its the opening of the old workbook that i need help with. I have no way on knowing what they have named there OLD workbook. I know there has to be a way to do this. Any ideas and suggestions are appreciated!!:help


Thanks!! This is driving me :cuckoo: !!
:beg:

Zack Barresse
04-04-2005, 12:33 PM
Hi there!

I'd make use of the GetOpenFilename method. An example can be found here ..

http://www.vbaexpress.com/forum/showthread.php?t=1631&page=2&pp=10&highlight=GetOpenFilename

Or might look like this ...

Sub foo()
Dim fName As String, wb As Workbook
fName = Application.GetOpenFilename("Excel Target Files (*.xls), *.xls")
If TypeName(fName) = "Boolean" Then Exit Sub
Set wb = Workbooks.Open(fName)
'other code here
End Sub

TButhe
04-04-2005, 12:57 PM
THANKS, I knew you could help me firefytr. You are the best!! :mbounce2:

Can't believe I missed the other post. But, hey the eyes (and brain) aren't what they used to be. :old:

Thanks again!
Tracy
:cloud9:

I'm going to mark this closed for now and try to get rest of the process on my own but don't be surprised if this comes up again. :*)

Zack Barresse
04-04-2005, 02:35 PM
You're welcome Tracy! :) I'm happy to help!!

If you have any other questions about this, don't hesitate to post back. :yes (And the other post was a little easier for me to find, as it was one I'd subscribed to! :D )