PDA

View Full Version : Solved: Disfunctional Function Statement



village_alchemist
09-02-2004, 02:04 PM
:blush Ok, this is embarrassing. I'm trying to add a function to some code and I'm getting a compile error: "Expected End Sub" with the End Function line highlighted and the execution line showing as function statement line. If I remove the function/end function statements and just set iEngHours, everything is fine.

I seem to have trashed my VBA help too (hangs on opening), but that's a separate problem...

Here is the code, any ideas?

Private Sub cmdHourQuote_Click()
Dim iEngHours As Integer

iEngHours = ProjectHours()

If iEngHours > 0 Then
MsgBox "This project will take approximately" & vbCrLf _
& Str(iEngHours) & " hours.", vbOKOnly + vbInformation, "Quick Hour Quote"
End If

End Sub
Private Function ProjectHours() As Integer
ProjectHours = 1
End Function

Jacob Hilderbrand
09-02-2004, 02:10 PM
Your code works fine for me as is on Word 2002. You may need to reinstall office (given the problem with VBA help crashing as well).

mdmackillop
09-02-2004, 02:32 PM
Works for me in 2000. Re the VBA help crash, I get that often. In Task Manager, shut the TWO msohelp processes to clear the problem.
MD

village_alchemist
09-02-2004, 06:17 PM
MD, thanks for the suggestion. That will be faster than re-installing office again. The re-install fixed the help issue, but not the expected end sub issue. In fact the problem kept getting worse until I finally realized that I had a macro virus. Seems one of the salesmen in my company sent me a nice little virus as gift and it infected my Normal template. Renamed (and subsequently deleted) the normal template and let word create a new one. All is well!

Zack Barresse
09-03-2004, 12:08 AM
... a nice little virus as gift ...

Sounds like a nice gift! :wot