Consulting

Results 1 to 4 of 4

Thread: Solved: Open workbook when excel starts

  1. #1
    VBAX Contributor
    Joined
    Dec 2006
    Posts
    193
    Location

    Solved: Open workbook when excel starts

    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


    [VBA]
    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
    [/VBA]

  2. #2
    VBAX Mentor Brandtrock's Avatar
    Joined
    Jun 2004
    Location
    Titonka, IA
    Posts
    399
    Location
    One way to do this would be to specify that the file be opened at startup by excel. Under Tools>Options you can specify files to open at startup. See below.
    Brandtrock




  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    If you put that code in the Personal.xls file, it will always happen at Excel startup, as that file (any any others in the XLSTART directory) are opened as Excel starts.

  4. #4
    VBAX Contributor
    Joined
    Dec 2006
    Posts
    193
    Location
    MANY THANKS I HAD FORGOTTEN ABOUT THE MXL START UP FOLDER

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •