VBA Macro to update or replace current name of file in code?
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: VBA Macro to update or replace current name of file in code?

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    357
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I have a macro that opens and closes other work books so I have a statement to activate the workbook that has the macro.

    Workbooks("Current.xls").Activate

    The thing is, this file gets saved ever now and then as a newer version, and I have to change that file name Current.xls to the new name every time I run that macro. How can I stop from having to do this? Something like


    ActiveWorkbook = ThisVersion

    Workbooks(ThisVersion).Activate

    Or

    Dim ActivateThisFile as String

    ActivateThisFile = ????

  2. #2
    MrExcel MVP Russell Hauf's Avatar
    Join Date
    Feb 2002
    Location
    Portland, OR Area - USA
    Posts
    1,605
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    If I'm understanding you correctly, you can do something like this:

    Dim wbk as Workbook

    Set wbk = ThisWorkbook

    '... your code

    wbk.Activate

    ___________________________

    Hope this helps,

    Russell

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com