By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

Sub or function not defined

P: n/a
Hello all,
When trying ro execute my program I get the mess "Sub or function not
defined"
The highlighted word is: "FindWindow"
Could somebody tell me which item I have to reference in the reference list?
Any help very much appreciated...
Thanks
Ronny
Public Function DetectExcel()
' Procedure dectects a running Excel and registers it.
Const WM_USER = 1024
Dim hWnd As Long
' If Excel is running this API call returns its handle.
hWnd = FindWindow("XLMAIN", 0)
If hWnd = 0 Then ' 0 means Excel not running.
Exit Function
Else
' Excel is running so use the SendMessage API
' function to enter it in the Running Object Table.
SendMessage hWnd, WM_USER + 18, 0, 0
End If
End Function
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Ronny Sigo" <ro********@skyynet.be> wrote in
news:40**********************@news.skynet.be:
Hello all,
When trying ro execute my program I get the mess "Sub or function not
defined"
The highlighted word is: "FindWindow"
Could somebody tell me which item I have to reference in the reference
list? Any help very much appreciated...
Thanks
Ronny
Public Function DetectExcel()
' Procedure dectects a running Excel and registers it.
Const WM_USER = 1024
Dim hWnd As Long
' If Excel is running this API call returns its handle.
hWnd = FindWindow("XLMAIN", 0)
If hWnd = 0 Then ' 0 means Excel not running.
Exit Function
Else
' Excel is running so use the SendMessage API
' function to enter it in the Running Object Table.
SendMessage hWnd, WM_USER + 18, 0, 0
End If
End Function


Note this line:
"If Excel is running this API call returns its handle."

When you copied this code it's likely that you left out this (perhaps more)

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long

at the top.
--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.