![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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).Ite ms 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 |
#2
|
|||
|
|||
![]()
So you're talking about a VBA user form (the topic of the
microsoft.public.outlook.program_vba newsgroup), not an Outlook custom form (the topic of this newsgroup)? And you're asking how to display that user form? To do that, you can write a macro that instantiates and shows it: Sub ShowMyUserForm() Set mySchool = New school school.Show End Sub You can customize any toolbar or the QAT in Outlook 2007 to add a button for any macro. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "cinnamngrl" wrote: 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).Ite ms 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 |
#3
|
|||
|
|||
![]()
On Sep 26, 6:19*pm, Sue Mosher [MVP-Outlook]
wrote: So you're talking about a VBA user form (the topic of the microsoft.public.outlook.program_vba newsgroup), not an Outlook custom form (the topic of this newsgroup)? And you're asking how to display that user form? To do that, you can write a macro that instantiates and shows it: Sub ShowMyUserForm() * * Set mySchool = New school * * school.Show End Sub You can customize any toolbar or the QAT in Outlook 2007 to add a button for any macro. -- Sue Mosher, Outlook MVP * *Author of Microsoft Outlook 2007 Programming: * * *Jumpstart for Power Users and Administrators * *http://www.outlookcode.com/article.aspx?id=54 Thank you. it works great. So this group is about customized the message class for outlook item types (contact, tasks, etc), but not "user forms". I 'm sure you can tell that I am stumbling aroung the dim part of the cave. |
#4
|
|||
|
|||
![]()
Correct. This group is about the form UI components that are unique to
Outlook -- published custom forms and, in Outlook 2007, form regions. The newsgroup for general Outlook programming issues, as well as VBA-specific issues such as user forms, is "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/comm....program_v ba -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "cinnamngrl" wrote: So this group is about customized the message class for outlook item types (contact, tasks, etc), but not "user forms". I 'm sure you can tell that I am stumbling aroung the dim part of the cave. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Open Custom Form | Nir | Outlook - Using Forms | 9 | May 2nd 08 07:11 PM |
new posts do not open in custom form | mash | Outlook - Using Forms | 6 | January 22nd 07 09:32 PM |
OL2003 - Custom form won't open on some PCs | Lanwench [MVP - Exchange] | Outlook - General Queries | 0 | November 28th 06 01:42 PM |
Is it possible to open the default Contact form with the Activities tab activated from a custom form? VSTO 2005, Outlook 2003 | David Webb | Outlook and VBA | 1 | June 20th 06 09:59 PM |
Cannot programmatically open custom message in custom form | ms | Outlook - Using Forms | 1 | January 20th 06 03:01 PM |