View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default Open File in Folder

It looks like Bob might have missed the spec that CurrMon is a variable. So,
replace this line of his code:

sFile = Dir("W:\comp\HRA Files\2007\CurrMon\*Pop*.xls")

With this

sFile = Dir("W:\comp\HRA Files\2007\" & CurrMon & "\*Pop*.xls")




"CV323" wrote:

The same thing happened, "file could not be found" I've checked and
re-checked the path.

"Bob Phillips" wrote:

Dim sFile
Dim myCell As Range
Dim mySht As Worksheet
Dim myName As String
Dim myArea As Range
Dim myShtName As String
Dim KeyCol As Integer
Dim CurrMon As String
Dim xlbook As Workbook
'Set the current month to look for files to use
CurrMon = InputBox("What Month is this report for?")
'Open the current month's HRA file
sFile = Dir("W:\comp\HRA Files\2007\CurrMon\*Pop*.xls")
Set xlbook = Workbooks.Open(sFile)


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"CV323" wrote in message
...
Can anyone tell me why this isn't working Please?
Basically, the files are saved in a folder (CurrMonth), and within the
current month's folder I want it to open the file that has the word "Pop"
in
it.

Dim sFile
Dim myCell As Range
Dim mySht As Worksheet
Dim myName As String
Dim myArea As Range
Dim myShtName As String
Dim KeyCol As Integer
Dim CurrMon As String
Dim xlbook As Workbook
'Set the current month to look for files to use
CurrMon = InputBox("What Month is this report for?")
'Open the current month's HRA file
sFile = Workbooks.Open( _
" W:\comp\HRA Files\2007\CurrMon\*Pop*.xls")
Set xlbook = Workbooks.Open(sFile)