+ Reply to Thread
Results 1 to 4 of 4

Macro code to open file.

  1. #1
    Forum Contributor
    Join Date
    10-31-2013
    Location
    india
    MS-Off Ver
    Excel 2019
    Posts
    147

    Macro code to open file.

    Dear Sir,

    Kindly provide me a macro code for the below mentioned scenario

    I have a excel file in the following path

    D:\TEST\1121_10.10.2023_RAGHU.xlsx

    I want to open the file as

    D:\TEST\1121_RAGHU.xlsx

    Regards

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,760

    Re: Macro code to open file.

    You cannot open a file with a different name than the file actually has.

    Do you mean that you want to save a copy of the file, using a different name?

    Do you mean that you want to change the name of the file then open it with the new name?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    10-31-2013
    Location
    india
    MS-Off Ver
    Excel 2019
    Posts
    147

    Re: Macro code to open file.

    I want to change the name of the file as 1121_raghu.xlsx and then open the file

    The _10.10.2023 should be removed. If it 11.10.2023 then _11.10.2023 to be removed and the file to be opened

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hello, try this !


    According to your explanation a VBA demonstration for starters :

    PHP Code: 
    Sub Demo1()
           Const 
    "D:\TEST\", Bill = P & "1121_RAGHU.xlsx"
           F$ = Dir$(P & "
    1121_??.??.????_RAGHU.xlsx")
        If F > "" Then
            If Dir(Bill) > "" Then Kill Bill
            Name P & F As Bill
            Workbooks.Open Bill, 0
        End If
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Creating Macro Code to Open File in File Explorer
    By green4000 in forum Excel General
    Replies: 4
    Last Post: 02-09-2021, 05:43 PM
  2. Code for closing the file if its already open before MACRO activates
    By NikhilDixit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2017, 10:21 AM
  3. macro to open a xl file and run the code
    By excelhelpseeker in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-21-2014, 04:13 AM
  4. Replies: 0
    Last Post: 10-02-2013, 01:47 AM
  5. [SOLVED] Macro/VB code to open a file specified in cell
    By MHamid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-26-2013, 09:21 AM
  6. VBA for excel 2003. Open file dialog box, open 2007 file xlsx, continue with code
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2011, 12:12 AM
  7. [SOLVED] macro code to open most recent file.
    By in forum Excel General
    Replies: 4
    Last Post: 06-09-2005, 10:05 PM

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