Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
Use o Editor do Visual Basic para criar um formulário que permite que seus usuários interajam com seu programa VBA (Microsoft Visual Basic for Applications). Unlike an Outlook form, a Visual Basic for Applications form is not used to display an Outlook item, nor can a control on a Visual Basic for Applications form be bound to an item field.
Your Visual Basic for Applications program can use a Visual Basic for Applications user form to gather information from your users; your program can then use this information to set properties of new or existing Outlook items. For example, a program that creates a boilerplate mail message could use a Visual Basic for Applications form to allow the user to enter the specific information for the message to be sent. When the user closes the form, the program uses the information in the form to set the properties of the mail message and then sends the message.
The following sample uses the text in two text boxes to add information to a message before sending it.
Private Sub CommandButton1_Click()
Dim myMail As Outlook.MailItem
Set myMail = Application.CreateItem(olMailItem)
With myMail
.To = TextBox1.Text
.Subject = "Book overdue: " & TextBox2.Text
.Body = "Please return this book as soon as possible."
End With
myMail.Send
End Sub
You can also use controls to display information about Outlook items, folders, and other features of the Outlook object model. O exemplo a seguir mostra como preencher um controle de caixa de combinação com os sujeitos dos itens na caixa de entrada do usuário.
Dim myItems As Outlook.Items
Set myItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
For x = 1 To myItems.Count
ComboBox1.AddItem myItems.Item(x).Subject
Next x
For more information about creating and using forms in the Visual Basic Editor, see the Visual Basic Editor Help.
Suporte e comentários
Tem dúvidas ou quer enviar comentários sobre o VBA para Office ou sobre esta documentação? Confira Suporte e comentários sobre o VBA para Office a fim de obter orientação sobre as maneiras pelas quais você pode receber suporte e fornecer comentários.