Results 1 to 3 of 3

Thread: Macro in Excel

  1. #1
    New Lounger
    Join Date
    Jul 2005
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Would like to set a macro in Excel to access the "last file" that is in the Excel 2007 button and "Recent Documents". I was able to set that macro in Word but when I complete the same steps for the same macro in Excel, it returns the file that I chose when recording the macro. Is it possible to set this type of macro in Excel?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Does this do what you want?

    Code:
    Sub OpenRecent()
      On Error GoTo ErrHandler
      Application.RecentFiles(1).Open
      Exit Sub
    ErrHandler:
      MsgBox "Can't open " & Application.RecentFiles(1).Name, vbExclamation
    End Sub

  3. #3
    New Lounger
    Join Date
    Jul 2005
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='783300' date='07-Jul-2009 05:19']Does this do what you want?

    Code:
    Sub OpenRecent()
      On Error GoTo ErrHandler
      Application.RecentFiles(1).Open
      Exit Sub
    ErrHandler:
      MsgBox "Can't open " & Application.RecentFiles(1).Name, vbExclamation
    End Sub
    [/quote]

    Thanks, Hans! There is no way I would have ever figured that one out!

Posting Permissions

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