BENSON
02-19-2007, 12:47 AM
I found the following code in prevoius thread "Open workbook based on specific date" could the code be modified to open the workbook whenever excel is opened
MANY thanks
Option Explicit
Private Sub Workbook_Open()
ProcessFiles
End Sub
Sub ProcessFiles()
Dim MyPath As String, MyName As String
Dim Sheet As String, Address As String
Dim d As Long
MyPath = "C:\AAA\"
MyName = "TestDate.xls"
For d = 10 To 30
If GetData(MyPath, MyName, "Sheet1", "A" & d) = Date Then
Workbooks.Open (MyPath & MyName)
Exit For
End If
Next
End Sub
Private Function GetData(Path, File, Sheet, Address)
Dim Data As String
Data = "'" & Path & "[" & File & "]" & Sheet & "'!" & _
Range(Address).Range("A1").Address(, , xlR1C1)
GetData = ExecuteExcel4Macro(Data)
End Function
MANY thanks
Option Explicit
Private Sub Workbook_Open()
ProcessFiles
End Sub
Sub ProcessFiles()
Dim MyPath As String, MyName As String
Dim Sheet As String, Address As String
Dim d As Long
MyPath = "C:\AAA\"
MyName = "TestDate.xls"
For d = 10 To 30
If GetData(MyPath, MyName, "Sheet1", "A" & d) = Date Then
Workbooks.Open (MyPath & MyName)
Exit For
End If
Next
End Sub
Private Function GetData(Path, File, Sheet, Address)
Dim Data As String
Data = "'" & Path & "[" & File & "]" & Sheet & "'!" & _
Range(Address).Range("A1").Address(, , xlR1C1)
GetData = ExecuteExcel4Macro(Data)
End Function