C
cinnamngrl
I created a custom form to record information (school attendance) and
convert that information to a journal note for a contact. What I
can't figure out is how/where to put a button or a menu item in
Outlook so I can access the info easily. the only way I can do it now
is to open VB editor, go to form, View code, run code. This form is
set up to repeat itself because it takes so long to open the form I
try to do the data entry in batches. This is not a customized
outlook form, it is just a small pop up box with five text boxes.
I created a button on contact form that creates an email with the
contact in the subject line.
Sub CommandButton1_Click()
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Subject= Item.Fullname & " " & Item.User1
myItem.Display
End Sub
But this new form will search for the correct contact, and I want to
put the button in the tool bar.
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} school
Caption = "UserForm1"
ClientHeight = 3675
ClientLeft = 45
ClientTop = 330
ClientWidth = 3825
OleObjectBlob = "school.frx":0000
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "school"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Function item_open()
End Function
Private Sub CommandButton1_Click()
school.Hide
lname = TextBox1.Text
mydate = TextBox2.Text
absent = TextBox3.Text
tardy = TextBox4.Text
present = TextBox5.Text
TextBox1.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection
TextBox2.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection
TextBox3.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection
TextBox4.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection
TextBox5.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection
TextBox2.Value = mydate
school.Hide
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set allcontacts =
myNameSpace.GetDefaultFolder(olFolderContacts).Items
Set mycontacts = allcontacts.Restrict("[Categories]="" caseload""")
line1:
If lname = "" Then
finame = "unknown"
GoTo lineq
End If
Set myItems = mycontacts.Restrict("[LastName] = " & lname & "")
linet:
Dim who(1 To 10, 1 To 4)
For Each Itm In myItems
x = x + 1
who(x, 1) = Itm.FullName
who(x, 2) = Itm.User1
who(x, 3) = Itm.CompanyName
who(x, 4) = Itm.HomeAddress
Next
If x = 0 And notfound < 1 Then
finame = InputBox("What is first name?")
Set myItems = mycontacts.Restrict("[FirstName] = "" & finame & """)
notfound = notfound + 1
GoTo linet
End If
If notfound > 1 Then GoTo lineu
lineu:
lineq:
If x <> 0 Then
Set inq = Assistant.NewBalloon
With inq
.Heading = "Available in Contacts"
.Text = "Select one"
For i = 1 To x
.Labels(i).Text = who(i, 1) & " " & who(i, 2)
Next
.Button = msoButtonSetOK
Debug.Print where
End With
Select Case inq.Show
Case 1
fname = who(1, 1)
Case 2
fname = who(2, 1)
Case 3
fname = who(3, 1)
Case 4
fname = who(4, 1)
Case 5
fname = who(5, 1)
Case Else
notfound = notfound + 1
GoTo lineu
End Select
End If
If x = 0 Then
MsgBox ("Can't find this kid")
GoTo linend
End If
Debug.Print fname
Set myjournal = myOlApp.CreateItem(olJournalItem)
For Each Itm In myItems
If Itm.FullName = fname Then
myjournal.Subject = Itm.FullName
myjournal.Links.Add Itm
myjournal.Type = "Note"
fulldate = mydate & " 12:00:00 PM"
Debug.Print fulldate
myjournal.Start = fulldate
Debug.Print myjournal.Start
myschool = InputBox("Boston Public School Attendance as of " &
mydate & Chr(13) & "Absent: " & absent & Chr(13) & "Tardy: " & tardy
& Chr(13) & "from which school?", "check facts", Itm.CompanyName)
myjournal.Body = myschool & " Attendance as of " & mydate & Chr(13) &
"Absent: " & absent & Chr(13) & "Tardy: " & tardy & Chr(13) &
"Present: " & present
myjournal.Save
End If
Itm.CompanyName = myschool
Itm.Save
Next
TextBox1.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox2.Value = mydate
linend:
school.Show
End Sub
Private Sub UserForm_Click()
school.Hide
End Sub
convert that information to a journal note for a contact. What I
can't figure out is how/where to put a button or a menu item in
Outlook so I can access the info easily. the only way I can do it now
is to open VB editor, go to form, View code, run code. This form is
set up to repeat itself because it takes so long to open the form I
try to do the data entry in batches. This is not a customized
outlook form, it is just a small pop up box with five text boxes.
I created a button on contact form that creates an email with the
contact in the subject line.
Sub CommandButton1_Click()
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Subject= Item.Fullname & " " & Item.User1
myItem.Display
End Sub
But this new form will search for the correct contact, and I want to
put the button in the tool bar.
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} school
Caption = "UserForm1"
ClientHeight = 3675
ClientLeft = 45
ClientTop = 330
ClientWidth = 3825
OleObjectBlob = "school.frx":0000
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "school"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Function item_open()
End Function
Private Sub CommandButton1_Click()
school.Hide
lname = TextBox1.Text
mydate = TextBox2.Text
absent = TextBox3.Text
tardy = TextBox4.Text
present = TextBox5.Text
TextBox1.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection
TextBox2.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection
TextBox3.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection
TextBox4.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection
TextBox5.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection
TextBox2.Value = mydate
school.Hide
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set allcontacts =
myNameSpace.GetDefaultFolder(olFolderContacts).Items
Set mycontacts = allcontacts.Restrict("[Categories]="" caseload""")
line1:
If lname = "" Then
finame = "unknown"
GoTo lineq
End If
Set myItems = mycontacts.Restrict("[LastName] = " & lname & "")
linet:
Dim who(1 To 10, 1 To 4)
For Each Itm In myItems
x = x + 1
who(x, 1) = Itm.FullName
who(x, 2) = Itm.User1
who(x, 3) = Itm.CompanyName
who(x, 4) = Itm.HomeAddress
Next
If x = 0 And notfound < 1 Then
finame = InputBox("What is first name?")
Set myItems = mycontacts.Restrict("[FirstName] = "" & finame & """)
notfound = notfound + 1
GoTo linet
End If
If notfound > 1 Then GoTo lineu
lineu:
lineq:
If x <> 0 Then
Set inq = Assistant.NewBalloon
With inq
.Heading = "Available in Contacts"
.Text = "Select one"
For i = 1 To x
.Labels(i).Text = who(i, 1) & " " & who(i, 2)
Next
.Button = msoButtonSetOK
Debug.Print where
End With
Select Case inq.Show
Case 1
fname = who(1, 1)
Case 2
fname = who(2, 1)
Case 3
fname = who(3, 1)
Case 4
fname = who(4, 1)
Case 5
fname = who(5, 1)
Case Else
notfound = notfound + 1
GoTo lineu
End Select
End If
If x = 0 Then
MsgBox ("Can't find this kid")
GoTo linend
End If
Debug.Print fname
Set myjournal = myOlApp.CreateItem(olJournalItem)
For Each Itm In myItems
If Itm.FullName = fname Then
myjournal.Subject = Itm.FullName
myjournal.Links.Add Itm
myjournal.Type = "Note"
fulldate = mydate & " 12:00:00 PM"
Debug.Print fulldate
myjournal.Start = fulldate
Debug.Print myjournal.Start
myschool = InputBox("Boston Public School Attendance as of " &
mydate & Chr(13) & "Absent: " & absent & Chr(13) & "Tardy: " & tardy
& Chr(13) & "from which school?", "check facts", Itm.CompanyName)
myjournal.Body = myschool & " Attendance as of " & mydate & Chr(13) &
"Absent: " & absent & Chr(13) & "Tardy: " & tardy & Chr(13) &
"Present: " & present
myjournal.Save
End If
Itm.CompanyName = myschool
Itm.Save
Next
TextBox1.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox2.Value = mydate
linend:
school.Show
End Sub
Private Sub UserForm_Click()
school.Hide
End Sub