Consulting

Results 1 to 5 of 5

Thread: How to define stop in "send" button in custom form?

  1. #1
    VBAX Newbie
    Joined
    May 2015
    Posts
    3
    Location

    How to define stop in "send" button in custom form?

    Hi,
    I`ve been working on custom form for "request meeting" in outlook 2013 lately. As in subject I am not able (with my knowledge) create code in form to define STOP submitting if ,let`s say, textbox1.value <> "YES" ? Maybe it`s totally dumb question but i cannot find anything in web about that kind of problem, maybe i`m asking wrong question?

    Any known by me commands do not work with "Function Item_Send()" script in form. Do You have any ideas?

    Thank You very much in advance for all help!

  2. #2
    Without seeing your code it is difficult to be precise but on the face of it

    If Not UCase(textbox1.Text) = "YES" then Exit Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Newbie
    Joined
    May 2015
    Posts
    3
    Location
    Hi,
    Maybe my question wasn`t clear enough. Only script in custom form VBscript related to "submitt" is function "Function Item_Send()" , after clicking "send" this function is called but "end function" or "end sub" is not working. Form is sent anyway. I found sth like this:

    Public WithEvents myOlApp As Outlook.Application
    
    Public Sub Initialize_handler()
    	Set myOlApp = CreateObject("Outlook.Application")
    End Sub
    
    Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
    	Dim prompt As String
    	prompt = "Are you sure you want to send " & Item.Subject & "?"
    	If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
    		Cancel = True
    	End If
    End Sub
    But i cannot define boolean in VBscript and it`s returning error for code like above. I`m new in custom forms and i don`t know how to create relation to already created code - SEND.

  4. #4
    If you put the following in the ThisOutlookSession module

    Option Explicit
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim prompt As String
        prompt = "Are you sure you want to send " & Item.Subject & "?"
        If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
            Cancel = True
        End If
    End Sub
    It should fire when you click Send on your form and should cancel if cancelled. It certainly does with the preconfigured forms.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  5. #5
    VBAX Newbie
    Joined
    May 2015
    Posts
    3
    Location
    Thank You very much, it works Finally i see my mistake, i was trying to implement code inside form code, not Outlook VBA as global sub.
    Is there any possibilty to write code as above inside form? I want to distribute it for some users and is there any possibilty to bypass outlook vba and write everything in custom form (VBscript)?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •