Excel User Group
Microsoft Excel blogs, forums, files. Read, ask questions, provide answers.

automatic opening excel sheet...........i am not able to figure this out............please help

Latest post Fri, Jun 6 2008 6:25 PM by Nick Hodge. 1 replies.
  • Fri, Jun 6 2008 11:04 AM

    • venu
    • Top 75 Contributor
    • Joined on Tue, Jun 3 2008
    • Posts 4
    • Points 100

    automatic opening excel sheet...........i am not able to figure this out............please help

    Dear all , please help me writing the code for opening the excel sheet automatically at a particular time and print the sheet and save it to a particular location along with the time stamp on it and exiting automatically when the job is done.............................

    Thanks

    • Post Points: 21
  • Fri, Jun 6 2008 6:25 PM In reply to

    • Nick Hodge
    • Top 10 Contributor
    • Joined on Sun, Dec 23 2007
    • Southampton
    • Posts 234
    • Points 3,866
    • MVP

    Re: automatic opening excel sheet...........i am not able to figure this out............please help

    venu

    You will need to set up your workbook to 'spin' off a new workbook at a set time. Your original workbook will need to have an OnTime setting to fire your necessary code, so enter

    Sub FireAtCertainTime()
    Application.OnTime TimeValue("23:00:00"), "Firecode"
    End Sub

    This will then fire the FireCode code snippet (in your originating workbook too) that will open your file (change YourFilename to whatever you have), print it and then close it with the file name yyyymmdd.xls. it then closes the workbook and re-runs the FireatCertainTime code ready for the next day at 11pm

    Sub FireCode()
    Dim wb As Workbook

    Set wb = Workbooks.Open("YourFilename")

    With wb
        .PrintOut
        .SaveAs Filename:="YourFilePathAnd" & "\" & Year(Now()) & Month(Now()) & Day(Now()) & ".xls"
        .Close
    End With

    Set wb = Nothing
    FireAtCertainTime
    End Sub

    Regards
    Nick Hodge
    Microsoft MVP, Excel
    Southampton, UK

    Filed under:
    • Post Points: 5
Page 1 of 1 (2 items) | RSS
Copyright Excel User Group and the relevant contributors, 2008. All Trade Marks acknowledged. This site is a peer-to-peer site and NOT affiliated in any way to Microsoft Corp. All rights reserved.