Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default VB Editor complains of undefined variable for VBE

I have a project that uses an add in to deliver most of the functionality.
This included a proprietary save in which I store data on the sheet for the
next time.
A request was made to be able to "minimise" the form to look at the sheet. I
put this in but this then exposed a method by which the user can save using
excels save not using the forms methods that store vital data before the user
exits.

To catch this I need to put a workbook_beforesave() event in to the
worksheet itself to call a function in the addin to do the stores as if the
user had used the form save.


I have used code from http://www.cpearson.com/excel/vbe.htm but when I
compile/run I get variable not defined errors on the "vbext_pk_Proc"

Function ProcedureExists(ProcedureName As String, ModuleName As String) As
Boolean
On Error Resume Next
If ModuleExists(ModuleName) = True Then
ProcedureExists = ThisWorkbook.VBProject.VBComponents(ModuleName) _
.CodeModule.ProcStartLine(ProcedureName, vbext_pk_Proc) < 0
End If
End Function

I tried Dim vbext_pk_Proc as ProcKind, but then I just got a user defined
type error

Looking in my object browser I don't seem to have the vbext_< set of
declarations but I can't figure how to reference it.

Help!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default VB Editor complains of undefined variable for VBE

Have you referenced The VBA Extensibility Tools as described in the article.

in the VBE Tools - References - Microsoft VB... (depending on you version)

HTH

"Alan Glaister" wrote:

I have a project that uses an add in to deliver most of the functionality.
This included a proprietary save in which I store data on the sheet for the
next time.
A request was made to be able to "minimise" the form to look at the sheet. I
put this in but this then exposed a method by which the user can save using
excels save not using the forms methods that store vital data before the user
exits.

To catch this I need to put a workbook_beforesave() event in to the
worksheet itself to call a function in the addin to do the stores as if the
user had used the form save.


I have used code from http://www.cpearson.com/excel/vbe.htm but when I
compile/run I get variable not defined errors on the "vbext_pk_Proc"

Function ProcedureExists(ProcedureName As String, ModuleName As String) As
Boolean
On Error Resume Next
If ModuleExists(ModuleName) = True Then
ProcedureExists = ThisWorkbook.VBProject.VBComponents(ModuleName) _
.CodeModule.ProcStartLine(ProcedureName, vbext_pk_Proc) < 0
End If
End Function

I tried Dim vbext_pk_Proc as ProcKind, but then I just got a user defined
type error

Looking in my object browser I don't seem to have the vbext_< set of
declarations but I can't figure how to reference it.

Help!!!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VB Editor complains of undefined variable for VBE

Sounds like you need to instantiate application level events in your addin.

for documentation and some explanation on Application Level Events, you
might want to read Chip Pearson's site
http://www.cpearson.com/excel/appevent.htm

this reflects the method presented in VBA help, but see this simpler, more
logical method suggested by KeepitCool and Further endorsed by Jamie Collins
and which uses only the Thisworkbook class module (eliminating the need to
instantiate the class and which keeps everything in one place)

[KeepitCool, otherwise known as Jurgen Volkerink @ www.XLsupport.com ]

Some discussion:
http://groups.google.co.uk/groups?se....microsoft.com
the thread:
http://groups.google.co.uk/groups?th....microsoft.com

Source of article below:
http://groups.google.co.uk/groups?se....microsoft.com

From: keepITcool )
Subject: Using Events with the Application Object & XL 2003


View this article only
Newsgroups: microsoft.public.excel.programming
Date: 2005-01-23 18:47:05 PST



What Chip doesn't mention and what I find a lot easier...

you dont need a separate class module..
Thisworkbook IS a class module so you can keep all your code
(and the withevents application variable) there.

'thisworkbook code module...
Option Explicit

Private WithEvents XlsEvents As Application

Private Sub Workbook_Open()
Set XlsEvents = Application
End Sub

Private Sub XlsEvents_WorkbookOpen(ByVal Wb As Workbook)
MsgBox "You just opened " & Wb.Name
End Sub

--
Regards,
Tom Ogilvy
"Alan Glaister" wrote in message
...
I have a project that uses an add in to deliver most of the functionality.
This included a proprietary save in which I store data on the sheet for

the
next time.
A request was made to be able to "minimise" the form to look at the sheet.

I
put this in but this then exposed a method by which the user can save

using
excels save not using the forms methods that store vital data before the

user
exits.

To catch this I need to put a workbook_beforesave() event in to the
worksheet itself to call a function in the addin to do the stores as if

the
user had used the form save.


I have used code from http://www.cpearson.com/excel/vbe.htm but when I
compile/run I get variable not defined errors on the "vbext_pk_Proc"

Function ProcedureExists(ProcedureName As String, ModuleName As String) As
Boolean
On Error Resume Next
If ModuleExists(ModuleName) = True Then
ProcedureExists = ThisWorkbook.VBProject.VBComponents(ModuleName) _
.CodeModule.ProcStartLine(ProcedureName, vbext_pk_Proc) < 0
End If
End Function

I tried Dim vbext_pk_Proc as ProcKind, but then I just got a user defined
type error

Looking in my object browser I don't seem to have the vbext_< set of
declarations but I can't figure how to reference it.

Help!!!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default VB Editor complains of undefined variable for VBE

Thanks Jim,

When I checked the references I had selected the wrong reference, now that
I've added in the extensibility reference it compiles.

Thanks for all the help and suggestions from Tom as well

"Jim Thomlinson" wrote:

Have you referenced The VBA Extensibility Tools as described in the article.

in the VBE Tools - References - Microsoft VB... (depending on you version)

HTH

"Alan Glaister" wrote:

I have a project that uses an add in to deliver most of the functionality.
This included a proprietary save in which I store data on the sheet for the
next time.
A request was made to be able to "minimise" the form to look at the sheet. I
put this in but this then exposed a method by which the user can save using
excels save not using the forms methods that store vital data before the user
exits.

To catch this I need to put a workbook_beforesave() event in to the
worksheet itself to call a function in the addin to do the stores as if the
user had used the form save.


I have used code from http://www.cpearson.com/excel/vbe.htm but when I
compile/run I get variable not defined errors on the "vbext_pk_Proc"

Function ProcedureExists(ProcedureName As String, ModuleName As String) As
Boolean
On Error Resume Next
If ModuleExists(ModuleName) = True Then
ProcedureExists = ThisWorkbook.VBProject.VBComponents(ModuleName) _
.CodeModule.ProcStartLine(ProcedureName, vbext_pk_Proc) < 0
End If
End Function

I tried Dim vbext_pk_Proc as ProcKind, but then I just got a user defined
type error

Looking in my object browser I don't seem to have the vbext_< set of
declarations but I can't figure how to reference it.

Help!!!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Functions Undefined James O. Thompson Excel Worksheet Functions 2 January 20th 09 10:41 PM
Undefined function error CLamar Excel Discussion (Misc queries) 3 June 5th 06 07:07 PM
Excel complains about "C:\documents.xls", etc. when starting MxlPltx Setting up and Configuration of Excel 4 June 13th 05 10:24 PM
Undefined unction when using VLOOKUP cici Excel Programming 2 February 10th 04 10:06 PM
Variable Undefined When Blank Mike[_41_] Excel Programming 0 August 5th 03 01:53 PM


All times are GMT +1. The time now is 07:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"