Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 91
Default Opening a xl workbook using wildcard

Hi,
I am using an input box to to select a folder for where the .xls
workbook is
##########
Sub Macro3()
Dim i As String
i = InputBox("Enter Job Number", , "Job Number")
Workbooks.Open Filename:="C:\" & i & "\Kicking Quotes.xls"
End Sub

#########
Each folder has 1 workbook but the workbook does not always have the
same name.

How can I open whatever workbook is in the folder selected?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,718
Default Opening a xl workbook using wildcard

This opens the first XLS file that the Dir function returns:

Sub a()
Dim DName As String
Dim FName As String
DName = InputBox("Enter Job Number", , "Job Number")
If DName < "" Then
FName = Dir("C:\" & DName & "\*.xls")
If FName < "" Then
Workbooks.Open "C:\" & DName & "\" & FName
End If
End If
End Sub


--
Jim
"damorrison" wrote in message
...
| Hi,
| I am using an input box to to select a folder for where the .xls
| workbook is
| ##########
| Sub Macro3()
| Dim i As String
| i = InputBox("Enter Job Number", , "Job Number")
| Workbooks.Open Filename:="C:\" & i & "\Kicking Quotes.xls"
| End Sub
|
| #########
| Each folder has 1 workbook but the workbook does not always have the
| same name.
|
| How can I open whatever workbook is in the folder selected?
|
| Thanks

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 91
Default Opening a xl workbook using wildcard

On Sep 23, 5:22*am, "Jim Rech" wrote:
This opens the first XLS file that the Dir function returns:

Sub a()
* * Dim DName As String
* * Dim FName As String
* * DName = InputBox("Enter Job Number", , "Job Number")
* * If DName < "" Then
* * * * FName = Dir("C:\" & DName & "\*.xls")
* * * * If FName < "" Then
* * * * * * Workbooks.Open "C:\" & DName & "\" & FName
* * * * End If
* * End If
End Sub

Thank You very much.
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
opening a file with wildcard Dode Excel Discussion (Misc queries) 1 December 14th 07 03:08 PM
when opening an Excel Workbook, another blank workbook also opens Gord Dibben Excel Discussion (Misc queries) 0 October 12th 07 09:49 PM
when opening an Excel Workbook, another blank workbook also opens spmu Excel Discussion (Misc queries) 0 October 12th 07 01:46 PM
Using a Wildcard (*) in formula accessing sheets in workbook. pwk Excel Worksheet Functions 1 February 4th 07 06:47 PM
Opening workbook Todd D. Excel Discussion (Misc queries) 4 September 14th 06 07:10 PM


All times are GMT +1. The time now is 06:03 PM.

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"