Problem with a personnalized function

J

Jac Tremblay

Hi everyone
I have a couple of simple functions that return the workbook name and its file save date. They are in a module named modMain. When I test my application in debug mode (F8), the program flow goes to those functions when it should not. It's is irrelevant. I have to comment them out until it is time to deliver my application (a simple workbook in which those functions are used to show the file name and its version number (save date)
Here is the code
' ******************************************************************
Private Function WbkName() As Strin
WbkName = ActiveWorkbook.Nam
End Functio

' ******************************************************************
Private Function WbkDate() As Strin
Dim strXlName As Strin
Dim strXlPath As Strin
Dim datDateXl As Strin

strXlName = ActiveWorkbook.Nam
strXlPath = ActiveWorkbook.pat
If Right(strXlPath, 1) <> "\" Then strXlPath = strXlPath & "\
datDateXl = FileDateTime(strXlPath & strXlName
WbkDate = Format(datDateXl, "d mmmm yyyy"
End Functio
' ******************************************************************
Thanks.
 
B

billyb

I assume you've entered your two functions directly into your Exce
worksheet rather than calling them from VBA. If so, the reason they'r
activating so often is that each time the worksheet recalculates, i
recalculates ALL formulas, functions, etc., including any user-define
functions such as your two. If you call your functions from a VBA sub
they won't activate unless and until you run the sub.

Try putting this sub in your modMain and running it in debug (o
otherwise):

Sub GetBookInfo()
Dim wn as String, wd as String
wn = wbkname
wd = wbkdate
Msgbox "Book's name is " & wn & vbLf & "Its date is " & wd
End Sub

Regards,
billy
 
Top