Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default how to trap a event coming from a dll

Hello,
I use a mailer DLL in a module.
I set the properties and then kick the Send Method. This works fine so far.
To check whether a mail was sent correctly, the dll raises the event
SendSuccessful.
How can I trap this event??
Thanks for any help

Ernst


The "simple" code for the problem

Sub SendMails()
Dim Mymailer As Object
Set Mymailer = New vbSendMail.clsSendMail
With ThisWorkbook.Worksheets("Mail")
Mymailer.SMTPHost = .Range("MailSMTPHost").Value
Mymailer.from = .Range("MailFrom").Value
Mymailer.FromDisplayName = .Range("MailfromName").Value
Mymailer.ReplyToAddress = .Range("MailReplyTo").Value
Mymailer.Recipient = .Range("TestMailRecv").Value
Mymailer.Subject = .Range("Testmailbetreff").Value
Mymailer.Message = .Range("Testmailbody").Value
End With
Mymailer.Send

Mymailer.Send
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default how to trap a event coming from a dll

Ernst,

I'm guessing a bit here, but you should be able to insert a new class module into your VBA project and enter something like the
following at the top of the module:

Dim WithEvents myMailer as vbSendMail.clsSendMail

You shoud then be able to select the object and its events from the top of the module and write your event code.

--

John Green - Excel MVP
Sydney
Australia


"E.Anderegg" wrote in message ...
Hello,
I use a mailer DLL in a module.
I set the properties and then kick the Send Method. This works fine so far.
To check whether a mail was sent correctly, the dll raises the event
SendSuccessful.
How can I trap this event??
Thanks for any help

Ernst


The "simple" code for the problem

Sub SendMails()
Dim Mymailer As Object
Set Mymailer = New vbSendMail.clsSendMail
With ThisWorkbook.Worksheets("Mail")
Mymailer.SMTPHost = .Range("MailSMTPHost").Value
Mymailer.from = .Range("MailFrom").Value
Mymailer.FromDisplayName = .Range("MailfromName").Value
Mymailer.ReplyToAddress = .Range("MailReplyTo").Value
Mymailer.Recipient = .Range("TestMailRecv").Value
Mymailer.Subject = .Range("Testmailbetreff").Value
Mymailer.Message = .Range("Testmailbody").Value
End With
Mymailer.Send

Mymailer.Send
End Sub





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default how to trap a event coming from a dll

Thanks John, I can enter and write the code for the event-handling
Sorry,but I have not much experience with class modules...
So how can I now access the properties and methods of the DLL??

Ernst

Code so far:

Option Explicit
Dim WithEvents MyMail As vbSendMail.clsSendMail

Private Sub mymail_SendFailed(Explanation As String)
MsgBox "Mail failed with Reason:" & Explanation, vbOKOnly
End Sub

Private Sub mymail_SendSuccesful()
MsgBox "Mail successfil sent", vbOKOnly
End Sub



"John Green" schrieb im Newsbeitrag
...
Ernst,

I'm guessing a bit here, but you should be able to insert a new class

module into your VBA project and enter something like the
following at the top of the module:

Dim WithEvents myMailer as vbSendMail.clsSendMail

You shoud then be able to select the object and its events from the top of

the module and write your event code.

--

John Green - Excel MVP
Sydney
Australia


"E.Anderegg" wrote in message

...
Hello,
I use a mailer DLL in a module.
I set the properties and then kick the Send Method. This works fine so

far.
To check whether a mail was sent correctly, the dll raises the event
SendSuccessful.
How can I trap this event??
Thanks for any help

Ernst


The "simple" code for the problem

Sub SendMails()
Dim Mymailer As Object
Set Mymailer = New vbSendMail.clsSendMail
With ThisWorkbook.Worksheets("Mail")
Mymailer.SMTPHost = .Range("MailSMTPHost").Value
Mymailer.from = .Range("MailFrom").Value
Mymailer.FromDisplayName = .Range("MailfromName").Value
Mymailer.ReplyToAddress = .Range("MailReplyTo").Value
Mymailer.Recipient = .Range("TestMailRecv").Value
Mymailer.Subject = .Range("Testmailbetreff").Value
Mymailer.Message = .Range("Testmailbody").Value
End With
Mymailer.Send

Mymailer.Send
End Sub







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default how to trap a event coming from a dll

Ernst,

You need to create an instance of your class module. I'll assume that you have given the class module the default name of Class1
although it would be better to give it a more meaningful name.

Try something like the following in your original code:

Sub SendMails()
Dim Mymailer As Object '(or Dim Mymailer As vbSendMail.clsSendMail)
Dim oMail as Class1
Set Mymailer = New vbSendMail.clsSendMail
set oMail = New Class1
Set oMail.MyMail = Mymailer


This should establish the necessary links between the mail object and the event procedures.


--

John Green - Excel MVP
Sydney
Australia


"E.Anderegg" wrote in message ...
Thanks John, I can enter and write the code for the event-handling
Sorry,but I have not much experience with class modules...
So how can I now access the properties and methods of the DLL??

Ernst

Code so far:

Option Explicit
Dim WithEvents MyMail As vbSendMail.clsSendMail

Private Sub mymail_SendFailed(Explanation As String)
MsgBox "Mail failed with Reason:" & Explanation, vbOKOnly
End Sub

Private Sub mymail_SendSuccesful()
MsgBox "Mail successfil sent", vbOKOnly
End Sub



"John Green" schrieb im Newsbeitrag
...
Ernst,

I'm guessing a bit here, but you should be able to insert a new class

module into your VBA project and enter something like the
following at the top of the module:

Dim WithEvents myMailer as vbSendMail.clsSendMail

You shoud then be able to select the object and its events from the top of

the module and write your event code.

--

John Green - Excel MVP
Sydney
Australia


"E.Anderegg" wrote in message

...
Hello,
I use a mailer DLL in a module.
I set the properties and then kick the Send Method. This works fine so

far.
To check whether a mail was sent correctly, the dll raises the event
SendSuccessful.
How can I trap this event??
Thanks for any help

Ernst


The "simple" code for the problem

Sub SendMails()
Dim Mymailer As Object
Set Mymailer = New vbSendMail.clsSendMail
With ThisWorkbook.Worksheets("Mail")
Mymailer.SMTPHost = .Range("MailSMTPHost").Value
Mymailer.from = .Range("MailFrom").Value
Mymailer.FromDisplayName = .Range("MailfromName").Value
Mymailer.ReplyToAddress = .Range("MailReplyTo").Value
Mymailer.Recipient = .Range("TestMailRecv").Value
Mymailer.Subject = .Range("Testmailbetreff").Value
Mymailer.Message = .Range("Testmailbody").Value
End With
Mymailer.Send

Mymailer.Send
End Sub









  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default how to trap a event coming from a dll

You will need to declare oMail at the module level if it is to persist after your sub ends.

Move the Dim oMail as Class1 line to the declarations section at the top of your module.

--

John Green - Excel MVP
Sydney
Australia


"John Green" wrote in message ...
Ernst,

You need to create an instance of your class module. I'll assume that you have given the class module the default name of Class1
although it would be better to give it a more meaningful name.

Try something like the following in your original code:

Sub SendMails()
Dim Mymailer As Object '(or Dim Mymailer As vbSendMail.clsSendMail)
Dim oMail as Class1
Set Mymailer = New vbSendMail.clsSendMail
set oMail = New Class1
Set oMail.MyMail = Mymailer


This should establish the necessary links between the mail object and the event procedures.


--

John Green - Excel MVP
Sydney
Australia


"E.Anderegg" wrote in message ...
Thanks John, I can enter and write the code for the event-handling
Sorry,but I have not much experience with class modules...
So how can I now access the properties and methods of the DLL??

Ernst

Code so far:

Option Explicit
Dim WithEvents MyMail As vbSendMail.clsSendMail

Private Sub mymail_SendFailed(Explanation As String)
MsgBox "Mail failed with Reason:" & Explanation, vbOKOnly
End Sub

Private Sub mymail_SendSuccesful()
MsgBox "Mail successfil sent", vbOKOnly
End Sub



"John Green" schrieb im Newsbeitrag
...
Ernst,

I'm guessing a bit here, but you should be able to insert a new class

module into your VBA project and enter something like the
following at the top of the module:

Dim WithEvents myMailer as vbSendMail.clsSendMail

You shoud then be able to select the object and its events from the top of

the module and write your event code.

--

John Green - Excel MVP
Sydney
Australia


"E.Anderegg" wrote in message

...
Hello,
I use a mailer DLL in a module.
I set the properties and then kick the Send Method. This works fine so

far.
To check whether a mail was sent correctly, the dll raises the event
SendSuccessful.
How can I trap this event??
Thanks for any help

Ernst


The "simple" code for the problem

Sub SendMails()
Dim Mymailer As Object
Set Mymailer = New vbSendMail.clsSendMail
With ThisWorkbook.Worksheets("Mail")
Mymailer.SMTPHost = .Range("MailSMTPHost").Value
Mymailer.from = .Range("MailFrom").Value
Mymailer.FromDisplayName = .Range("MailfromName").Value
Mymailer.ReplyToAddress = .Range("MailReplyTo").Value
Mymailer.Recipient = .Range("TestMailRecv").Value
Mymailer.Subject = .Range("Testmailbetreff").Value
Mymailer.Message = .Range("Testmailbody").Value
End With
Mymailer.Send

Mymailer.Send
End Sub













  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default how to trap a event coming from a dll

Thanks - just there is something missing (probably a declaration or so),
because it always indicates
at the line set mymailer.mymail = mymailer
"methode or data object not found"
??

Now, in the class module "MailWrapper" I have:

Dim WithEvents MyMail As vbSendMail.clsSendMail

Private Sub mymail_SendFailed(Explanation As String)
MsgBox "Mail failed with Reason:" & Explanation, vbOKOnly
End Sub

Private Sub mymail_SendSuccesful()
MsgBox "Mail successfil sent", vbOKOnly
End Sub

In the Module1 I have:

Dim oMail As MailWrapper
Sub SendMails()
Dim MyMailer As Object

Set MyMailer = New vbSendMail.clsSendMail
Set oMail = New MailWrapper
Set oMail.MyMail = MyMailer
With ThisWorkbook.Worksheets("Mail")
MyMailer.SMTPHost = .Range("MailSMTPHost").Value
MyMailer.from = .Range("MailFrom").Value
MyMailer.FromDisplayName = .Range("MailfromName").Value
MyMailer.ReplyToAddress = .Range("MailReplyTo").Value
MyMailer.Recipient = .Range("TestMailRecv").Value
MyMailer.Subject = .Range("Testmailbetreff").Value
MyMailer.Message = .Range("Testmailbody").Value
End With
MyMailer.Send
'MsgBox MyMailer.Status, vbOKOnly


End Sub




"John Green" schrieb im Newsbeitrag
...
You will need to declare oMail at the module level if it is to persist

after your sub ends.

Move the Dim oMail as Class1 line to the declarations section at the top

of your module.

--

John Green - Excel MVP
Sydney
Australia


"John Green" wrote in message

...
Ernst,

You need to create an instance of your class module. I'll assume that

you have given the class module the default name of Class1
although it would be better to give it a more meaningful name.

Try something like the following in your original code:

Sub SendMails()
Dim Mymailer As Object '(or Dim Mymailer As vbSendMail.clsSendMail)
Dim oMail as Class1
Set Mymailer = New vbSendMail.clsSendMail
set oMail = New Class1
Set oMail.MyMail = Mymailer


This should establish the necessary links between the mail object and

the event procedures.


--

John Green - Excel MVP
Sydney
Australia


"E.Anderegg" wrote in message

...
Thanks John, I can enter and write the code for the event-handling
Sorry,but I have not much experience with class modules...
So how can I now access the properties and methods of the DLL??

Ernst

Code so far:

Option Explicit
Dim WithEvents MyMail As vbSendMail.clsSendMail

Private Sub mymail_SendFailed(Explanation As String)
MsgBox "Mail failed with Reason:" & Explanation, vbOKOnly
End Sub

Private Sub mymail_SendSuccesful()
MsgBox "Mail successfil sent", vbOKOnly
End Sub



"John Green" schrieb im Newsbeitrag
...
Ernst,

I'm guessing a bit here, but you should be able to insert a new

class
module into your VBA project and enter something like the
following at the top of the module:

Dim WithEvents myMailer as vbSendMail.clsSendMail

You shoud then be able to select the object and its events from the

top of
the module and write your event code.

--

John Green - Excel MVP
Sydney
Australia


"E.Anderegg" wrote in message
...
Hello,
I use a mailer DLL in a module.
I set the properties and then kick the Send Method. This works

fine so
far.
To check whether a mail was sent correctly, the dll raises the

event
SendSuccessful.
How can I trap this event??
Thanks for any help

Ernst


The "simple" code for the problem

Sub SendMails()
Dim Mymailer As Object
Set Mymailer = New vbSendMail.clsSendMail
With ThisWorkbook.Worksheets("Mail")
Mymailer.SMTPHost = .Range("MailSMTPHost").Value
Mymailer.from = .Range("MailFrom").Value
Mymailer.FromDisplayName = .Range("MailfromName").Value
Mymailer.ReplyToAddress = .Range("MailReplyTo").Value
Mymailer.Recipient = .Range("TestMailRecv").Value
Mymailer.Subject = .Range("Testmailbetreff").Value
Mymailer.Message = .Range("Testmailbody").Value
End With
Mymailer.Send

Mymailer.Send
End Sub













  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default how to trap a event coming from a dll

Sorry I found the detail....
The declaration in the class module has to be public not private ...
It works fine!

Many thanks for the help from "down under", you are just great!
Ernst
Switzerland

"E.Anderegg" schrieb im Newsbeitrag
...
Thanks - just there is something missing (probably a declaration or so),
because it always indicates
at the line set mymailer.mymail = mymailer
"methode or data object not found"
??

Now, in the class module "MailWrapper" I have:

Dim WithEvents MyMail As vbSendMail.clsSendMail

Private Sub mymail_SendFailed(Explanation As String)
MsgBox "Mail failed with Reason:" & Explanation, vbOKOnly
End Sub

Private Sub mymail_SendSuccesful()
MsgBox "Mail successfil sent", vbOKOnly
End Sub

In the Module1 I have:

Dim oMail As MailWrapper
Sub SendMails()
Dim MyMailer As Object

Set MyMailer = New vbSendMail.clsSendMail
Set oMail = New MailWrapper
Set oMail.MyMail = MyMailer
With ThisWorkbook.Worksheets("Mail")
MyMailer.SMTPHost = .Range("MailSMTPHost").Value
MyMailer.from = .Range("MailFrom").Value
MyMailer.FromDisplayName = .Range("MailfromName").Value
MyMailer.ReplyToAddress = .Range("MailReplyTo").Value
MyMailer.Recipient = .Range("TestMailRecv").Value
MyMailer.Subject = .Range("Testmailbetreff").Value
MyMailer.Message = .Range("Testmailbody").Value
End With
MyMailer.Send
'MsgBox MyMailer.Status, vbOKOnly


End Sub




"John Green" schrieb im Newsbeitrag
...
You will need to declare oMail at the module level if it is to persist

after your sub ends.

Move the Dim oMail as Class1 line to the declarations section at the top

of your module.

--

John Green - Excel MVP
Sydney
Australia


"John Green" wrote in message

...
Ernst,

You need to create an instance of your class module. I'll assume that

you have given the class module the default name of Class1
although it would be better to give it a more meaningful name.

Try something like the following in your original code:

Sub SendMails()
Dim Mymailer As Object '(or Dim Mymailer As vbSendMail.clsSendMail)
Dim oMail as Class1
Set Mymailer = New vbSendMail.clsSendMail
set oMail = New Class1
Set oMail.MyMail = Mymailer


This should establish the necessary links between the mail object and

the event procedures.


--

John Green - Excel MVP
Sydney
Australia


"E.Anderegg" wrote in message

...
Thanks John, I can enter and write the code for the event-handling
Sorry,but I have not much experience with class modules...
So how can I now access the properties and methods of the DLL??

Ernst

Code so far:

Option Explicit
Dim WithEvents MyMail As vbSendMail.clsSendMail

Private Sub mymail_SendFailed(Explanation As String)
MsgBox "Mail failed with Reason:" & Explanation, vbOKOnly
End Sub

Private Sub mymail_SendSuccesful()
MsgBox "Mail successfil sent", vbOKOnly
End Sub



"John Green" schrieb im Newsbeitrag
...
Ernst,

I'm guessing a bit here, but you should be able to insert a new

class
module into your VBA project and enter something like the
following at the top of the module:

Dim WithEvents myMailer as vbSendMail.clsSendMail

You shoud then be able to select the object and its events from

the
top of
the module and write your event code.

--

John Green - Excel MVP
Sydney
Australia


"E.Anderegg" wrote in message
...
Hello,
I use a mailer DLL in a module.
I set the properties and then kick the Send Method. This works

fine so
far.
To check whether a mail was sent correctly, the dll raises the

event
SendSuccessful.
How can I trap this event??
Thanks for any help

Ernst


The "simple" code for the problem

Sub SendMails()
Dim Mymailer As Object
Set Mymailer = New vbSendMail.clsSendMail
With ThisWorkbook.Worksheets("Mail")
Mymailer.SMTPHost = .Range("MailSMTPHost").Value
Mymailer.from = .Range("MailFrom").Value
Mymailer.FromDisplayName = .Range("MailfromName").Value
Mymailer.ReplyToAddress = .Range("MailReplyTo").Value
Mymailer.Recipient = .Range("TestMailRecv").Value
Mymailer.Subject = .Range("Testmailbetreff").Value
Mymailer.Message = .Range("Testmailbody").Value
End With
Mymailer.Send

Mymailer.Send
End Sub















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
Trap show toolbar event [email protected] Links and Linking in Excel 0 April 27th 07 04:16 PM
how can I trap the change event (Tab Press key) of these controls Padam Excel Worksheet Functions 1 August 10th 06 03:59 PM
how can I trap the change event (Tab Press key) of these controls Padam Excel Worksheet Functions 0 August 10th 06 02:41 PM
Trap Excel events from VB pat Excel Programming 0 August 18th 03 11:01 PM


All times are GMT +1. The time now is 09:04 AM.

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

About Us

"It's about Microsoft Excel"