+ Reply to Thread
Results 1 to 3 of 3

Excel 2007 : Auto Open File with Macro

Hybrid View

  1. #1
    Registered User
    Join Date
    10-05-2011
    Location
    USA, Maryland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Auto Open File with Macro

    Hi there,

    Having trouble with this code ATM,

    Sub WEEKLY_UPDATE()
    
        Application.ScreenUpdating = False
    
     
    
        Dim ThisPath As String
    
        ThisPath = "C:\DD\WW\FOLDER\"
    
        Workbooks.Open ActiveWorkbook.ThisPath & "" & Sheet1.TextBox2.Value
    
     
    
        Windows(Sheet1.TextBox2.Value).Activate
    
        Sheets("Hello").Select
    
        Range("EA2:EG12").Select
    
        Selection.Copy
    
        Windows(Sheet1.TextBox1.Value).Activate
    
        Range("B2").Select
    
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    
            :=False, Transpose:=False

    Basically, text box 2 is where I will key in the file name to open. However, I am getting this error,

    "Object doesn't support this property or method"

    All I want is before the macro starts to run, it will open up the file that I want. In addition, the path folder of the file must be prefix. So all I need is to change the text box value to the file name.

    Please help, thanks.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,454

    Re: Auto Open File with Macro

    It's difficult to test something like this without the workbook, worksheet(s), object(s), code, files to open, etc.

    Maybe you could upload a sample workbook and file(s) to test it with?

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Auto Open File with Macro

    ThisPath is a variable, it's not a property of the ActiveWorkbook object.

    Also you're not opening the workbook in TextBox1 - is that workbook already open? If so there's probably a much easier way to do this.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1