VBA MAcro for EXCEL - TechRepublic
Question
November 25, 2008 at 06:29 AM
obarcham

VBA MAcro for EXCEL

by obarcham . Updated 17 years, 7 months ago

I have copy my maco below. When I run it i get undefind object error.Has anyone any ideas or a better macro for doing this. The macro open a box asking for a user to selecta file(this will be an xlms file). This file name will then be used to edit a link to this spreadsheet.
Please someone help as its driving me nuts.Also sorry if this is post in the wrong place as I am a NOOBIE here.

Private Sub Select()

ChDrive “c:\”
ChDir “c:\Documents and Settings”

NewFN = Application.GetOpenFilename(FileFilter:=”Excel Files (*.xlsm), *.xlsm”, Title:=”Please select a file”)
If NewFN = False Then
‘ They pressed Cancel

MsgBox “Stopping because you did not select a file”

Exit Sub

Else
ActiveWorkbook.ChangeLink Name:= _
“G:\Timesheet template JANUARY Proj A to M 2008.xls”, NewName:= _
(NewFN) _
, Type:=xlExcelLinks

End If

End Sub

This discussion is locked

All Comments