Results 1 to 5 of 5

Issues with macro name when file name changes

Threaded View

pingwin77 Issues with macro name when... 05-15-2008, 03:31 PM
stevebriz Try: ... 05-15-2008, 04:22 PM
pingwin77 What would I replace with... 05-16-2008, 09:05 AM
stevebriz I am assuming that the file... 05-16-2008, 04:24 PM
pingwin77 That seems to have worked so... 05-19-2008, 09:23 AM
  1. #1
    Registered User
    Join Date
    10-03-2007
    Location
    Twin Cities, MN
    MS-Off Ver
    2003
    Posts
    83

    Issues with macro name when file name changes

    I have a work book that i am using as a template. I open the file, make my changes and save the file. Sometimes I need to reopen the file and make more changes at a later date.

    The button I have on the sheet is designed to go open a file in a location on our network, copy data, paste it into the current book I am working with, then close the second file. This works fine until the file I am working with gets saved with a new name.

    Is there anyway to have the VB script inset the current workbook name in to the scripting so it will reference the file no mater what the name changes to?

    The area in question is highlighted in BLUE


    Private Sub CommandButton1_Click()
    '
    ' AIS Gage List Update Macro
    ' Macro recorded 3/5/2008 by AIS / Mike Hemm
    '
    
    '
    Dim Msg, Style, Title, Response, MyString
    Msg = "Update may change selected equipment.  Are you sure you want to update the list ?  If yes, select no when asked to save changes."    ' Define message.
    Style = vbYesNo  ' Define buttons.
    Title = "Gage List Update"    ' Define title.
    Response = MsgBox(Msg, Style, Title, Help, Ctxt)
    
    If Response = vbYes Then    ' User chose Yes.
        Workbooks.Open Filename:= _
            "F:\certification\AIS Certmaker Gauge List.xls" ' Change this location whenever the gage list changes locations
        ActiveSheet.Range("B5:F300").Select
        Selection.Copy
        Windows("Forum Help.xls").Activate ' Change this name whenever the cert name changes (revisions)
        Range("B5").Select
        ActiveSheet.Paste
        Range("B5").Select
        Windows("AIS Certmaker Gauge List.xls").Activate
        ActiveWindow.Close
    Else
        Exit Sub
    End If
    
    End Sub
    Last edited by VBA Noob; 05-15-2008 at 03:45 PM.

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