Link to home
Start Free TrialLog in
Avatar of DMTechGrooup
DMTechGrooupFlag for United States of America

asked on

OUTLOOK MACRO - VBA - INPUTBOX - MINI CALENDAR

I have been helped by many here and I truly appreciate it. As I get new ideas.. I come here for guidance..

I have an outlook macro that asks a bunch of questions then generates a calendar event and opens MS word and fills in a template..

What I want to know know is the first question it asks is date.. and the user has to enter something like 2/27 for February 27th.. instead of that is there some type of mini calendar they can use to select the date?  Either and example or link is greatly appreciated.
SOLUTION
Avatar of Antagony1960
Antagony1960

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DMTechGrooup

ASKER

Ok I found the Month View Control.. created a UserForm1 with that control and all defaults left alone.. how do I call the form when you run the macro?

Here is the begining of the macro as it is cycling through the questions.
Sub RRAAppointment()
    Const MACRONAME = "RRA Appointment"
    Dim strName As String, strAddress As String, strCity As String, strState As String, strZip As String, strCAT As String, _
        strPhone As String, strAltPhone As String, strCBA As String, strMakeModel As String, strLoc As String, strPT1 As String, _
        strWarranty As String, strIssue As String, strPT As String, strDTE As Date, strTM As String, strDIR As String, olkAppt As Outlook.AppointmentItem, strDT As String, strPO As String
    
    strDTE = InputBox("Enter a date #/##", MACRONAME)
    strTM = InputBox("Enter a time slot :" & vbCrLf & vbCrLf & "(1) 8-11" & vbCrLf & "(2) 9-12" & vbCrLf & "(3) 10-1" & vbCrLf & "(4) 11-2" & vbCrLf & "(5) 3-6" & vbCrLf & "(6) 4-7" & vbCrLf, MACRONAME)
    strName = InputBox("Customer Name", MACRONAME)
    strAddress = InputBox("Address", MACRONAME)
    strDIR = InputBox("Directions", MACRONAME)
    strPT = InputBox("City/Location :" & vbCrLf & vbCrLf & "(1) E. St George" & vbCrLf & "(2) W. St George" & vbCrLf & "(3) S. St George" & vbCrLf & "(4) Bloomington" & vbCrLf & "(5) Bloomington Hills" & vbCrLf & "(6) Sun River" & vbCrLf & "(7) Ivins" & vbCrLf & "(8) Santa Clara" & vbCrLf & "(9) Washington" & vbCrLf & "(10) Hurricane" & vbCrLf & "(11) Corral Caynon" & vbCrLf & "(12) Mesquite" & vbCrLf & "(13) Cedar City" & vbCrLf & vbCrLf & "OR SPECIFIY CITY" & vbCrLf, MACRONAME)
    strPhone = InputBox("Phone", MACRONAME)
    strAltPhone = InputBox("Alterante phone", MACRONAME)
    strCBA = InputBox("Call Before Arrival minutes", MACRONAME)
    strMakeModel = InputBox("Enter a make/model", MACRONAME)
    strWarranty = InputBox("(C)ash (W)arranty or (P)arts Warranty", MACRONAME)
    strIssue = InputBox("Issue", MACRONAME)
    strPO = MsgBox("Print out work order?", vbQuestion + vbYesNo, "Work Order Printout")

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help.. I am very rusty as VB..

I added the OK button.. but I cant figure out what to put in the OnClick properties..

I googles around and nothing has worked.
Private Sub OK_Click()
vbOK
 
End Sub

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Very helpful, Thanks for your time and help it works great!  I am sure I will be asking new stuff in the future and hope I can get your help!  Thanks again.
Avatar of Antagony1960
Antagony1960

Glad to have helped. :-)
@DMTechGrooup:

I forgot to mention that if you've used the form's Tag and the function, as I described above, you will need to handle the eventuality of a user closing the form using its close button (x) rather than the OK button (you know that if a user can do something the wrong way they probably will). As things stand it will unload the form and cause the function to error. The workaround is easy though, just add this code to your user form:

    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
        Cancel = True 'Prevents the form unloading so its Tag property can still be read
        Me.Tag = "Cancel"
        Me.Hide
    End Sub

Or, if you don't want to give users an option to cancel, do something like this instead:

    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
        Cancel = True
        MsgBox "Select a date and click OK.", vbExclamation, "Not Allowed!"
    End Sub

Oops.. that UserForm code block should have this line at the top:

        If CloseMode > 0 Then Exit Sub

Otherwise it will still execute when it is closed legitimately from the function.
Thanks!