PC Review


Reply
Thread Tools Rate Thread

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

 
 
Composer
Guest
Posts: n/a
 
      9th Apr 2005
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!

 
Reply With Quote
 
 
 
 
Michael Kensy
Guest
Posts: n/a
 
      9th Apr 2005
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


--
Gruss Michael
 
Reply With Quote
 
Michael Kensy
Guest
Posts: n/a
 
      10th Apr 2005
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


--
cu Michael
 
Reply With Quote
 
Composer
Guest
Posts: n/a
 
      11th Apr 2005
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?

 
Reply With Quote
 
Michael Kensy
Guest
Posts: n/a
 
      13th Apr 2005
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

--
cu Michael
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
add button to standard menu bar bodhi2.71828@gmail.com Microsoft Excel Programming 2 28th Jan 2006 03:22 AM
Disabling the standard X-Button? DHallam Microsoft Excel Programming 3 22nd Jul 2005 05:41 PM
want to see custom form not standard contact form in personal form =?Utf-8?B?T2xkIEdlZXplcg==?= Microsoft Outlook Contacts 2 16th Jul 2005 07:32 AM
Fax Button on Standard Toolbar =?Utf-8?B?QnJ1Y2U=?= Microsoft Excel Misc 1 19th Apr 2005 10:35 PM
Standard Button Size presspley@hotmail.com Microsoft Excel Programming 0 24th Oct 2004 01:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:31 PM.