填充组合框 VBA
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17234742/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 15:56:02 来源:igfitidea点击:
Populating ComboBoxes VBA
提问by M?nica
I have this VBA code:
我有这个 VBA 代码:
Sub sendByCustomForm()
Dim olItem As Outlook.MailItem
Dim sText As String
If Application.ActiveExplorer.Selection.Count = 0 Then
MsgBox "No Items selected!", vbCritical, "Error"
Exit Sub
End If
For Each olItem In Application.ActiveExplorer.Selection
sText = olItem.Body
Set msg = Application.CreateItemFromTemplate("C:\myCustomForm.oft")
MsgBox sText, vbInformation, "alert"
With msg
'Set body format to HTML
.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
.HTMLBody = "<HTML><BODY>" + sText + "</BODY></HTML>"
.Display
End With
Next olItem
End Sub
That template has 2 ComboBoxes that I want to populate, but how can I do this?
该模板有 2 个我想要填充的 ComboBox,但我该怎么做呢?
When I try this:
当我尝试这个时:
msg.ComboBox1.AddItem "item"
it doesn't work...
它不起作用...
回答by Grant
Try this:
尝试这个:
'For Access
msg.ComboBox1.RowSource = msg.ComboBox1.Rowsource & ";'item'"
Update:
更新:
With ComboBox
.AddItem "Option 1"
.AddItem "Option 2"
.AddItem "Option 3"
End With
回答by artis_meditari
Sub emailfromexcel()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "[email protected]"
.BCC = thebcc
.Subject = "This subject"
.Body = "This body"
.Display
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub