View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
peter.thompson[_43_] peter.thompson[_43_] is offline
external usenet poster
 
Posts: 1
Default VBA newbie question


How do you "execute" a VBA "function". I'm trying to use the following
code (found on the net) to check whether a file exists when a workbook
is activated. If the file doesn't exist I want to save a copy of the
workbook as a given name "Master Template".

Function FileExist(sTestFile As String) As Boolean

sTestFile = "C:\Business Cases\Master Template.xls"
Dim lSize As Long
On Error Resume Next
lSize = -1
lSize = FileLen(sTestFile)
If lSize < -1 Then

ActiveWorkbook.SaveAs Filename:="C:\ROI Business Cases\Master
Template.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
End If

End Function


--
peter.thompson
------------------------------------------------------------------------
peter.thompson's Profile: http://www.excelforum.com/member.php...o&userid=29686
View this thread: http://www.excelforum.com/showthread...hreadid=501319