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
Bookmarks