Add button to standard form, and can never use VBA with it?

C

Composer

Is the following really true?

If I want to add a button to a standard form (ie. Appointment), then
the event handler for that button must be written in VBS...

VBS code can never call VBA code...

The many lines of VBA code that I've already implemented for
interfacing Outlook to another application are going to have to be
rewritten (or converted) into VBS just for this one button...

Please tell me this isn't true!
 
M

Michael Kensy

Hallo Composer,

Samstag, den 09 April 2005 schrieb Composer:
If I want to add a button to a standard form (ie. Appointment), then
the event handler for that button must be written in VBS...

VBS code can never call VBA code...


I'am not sure about that, but I don't think so ... I think Sue told me
about an unsopported way to call vba-code from your forms scripting. I
remember something like you have to place your routine at "this outlook
session" and call it inside your forms script like "application.myroutine"

The many lines of VBA code that I've already implemented for
interfacing Outlook to another application are going to have to be
rewritten (or converted) into VBS just for this one button...

Please tell me this isn't true!


you shouldn't do and it isn't necessary, why you think so? I would prefer
to dimension your forms command button "with events" at your existing
vba-code. During open-event you have to refer that button

'***Put that code at the beginning of a class module and
Dim WithEvents mctrlPrintMe As CommandButton

'*** ...somewhere at your forms open event
Set mctrlPrintMe = mctrlControls2("NamePropertyOfYourButton") '

'***...somewhere at your forms close event
Set mctrlPrintMe = Nothing
 
M

Michael Kensy

Hi,

sorry I forgot to tell you ... my code wants you dimension and reference
'mctrlControls2' controls of page 2 (or any other page number containing
your command button) also
 
C

Composer

Michael, many thanks! It is very useful to know that VBS can call a
VBA routine that's coded within the ThisOutlookSession module!

I would also like to try your other suggestion, having a class module
refer to my form and button using WithEvents. But how do I connect the
form to the class module when the form is opened? Or can the class
module refer to the form without regard to whether it's open or closed?
And what is the name of a form which started as a delivered form but
to which I added a button?

Thanks again.

You'll see that I've posted another question about passing the Item
object from VBS to VBA and typecasting it to the correct type of item.
Perhaps you'll have some input there too?
 
M

Michael Kensy

Hi Composer,

Montag, den 11 April 2005 schrieb Composer:
I would also like to try your other suggestion, having a class module
refer to my form and button using WithEvents. But how do I connect the
form to the class module when the form is opened?


I don't know a way to do that time. The only way I know is to develop a
system of 'withEvent' variables from the beginning of every outlook session
.... you spoke of so many code you wrote, so I imagine you should have such
system already.

To get aware of an item-open event you could instance inspectors objects
like

Private WithEvents mcolInsp As Outlook.Inspectors
Private WithEvents mobjInsp As Outlook.Inspector

After that you will find mcolInsp as an object at your class module and you
can write some code for the 'NewInspector' event of that object. So every
time you open any item that code will get triggered. For me that seems to
be right place to instance one more 'WithEvents' variable connecting to
your form like

Private Sub mcolInsp_NewInspector(ByVal Inspector As Inspector)
Set mobjInsp = Inspector
End Sub

The mobjInsp variable will give you some more events like 'Activate' you
have to use to keep control of the item you are using also contains your
command button ...


Or can the class
module refer to the form without regard to whether it's open or closed?


to control an item whether it's opened or closed you have to use explorers
selection event ...

And what is the name of a form which started as a delivered form but
to which I added a button?

Thanks again.

You'll see that I've posted another question about passing the Item
object from VBS to VBA and typecasting it to the correct type of item.
Perhaps you'll have some input there too?


sorry, I don't understand that question
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top