我有一个Outlook宏失败,运行时错误1004“对话框类的show方法失败”在线:
xlApp.Dialogs(xlDialogColorPalette).Show
代码的相关部分(或者我认为)是:
Private WithEvents oExpl As Explorer
Private WithEvents oItem As MailItem
Private WithEvents respItem As MailItem
Private xlApp As Excel.Application
Private bDiscardEvents As Boolean
Private Sub Application_Startup()
Set xlApp = CreateObject("Excel.Application")
Set oExpl = Application.ActiveExplorer
bDiscardEvents = False
End Sub
Private Sub respItem_Send(cancel As Boolean)
bDiscardEvents = True
Dim orgbody As String
orgbody = respItem.HTMLBody
xlApp.Dialogs(xlDialogColorPalette).Show
非常感谢!
答案 0 :(得分:0)
根据公共xlApp
变量的想法,可以解决一些最小的代码:
Option Explicit
Private xlApp As Excel.Application
Sub TestMe()
Set xlApp = CreateObject("Excel.Application")
Dim someWb As Workbook
Set someWb = xlApp.Workbooks.Add
xlApp.Visible = True
If xlApp.Dialogs(xlDialogEditColor).Show(56) Then
someWb.Worksheets(1).Range("A1").Interior.Color = ActiveWorkbook.Colors(56)
End If
End Sub
这些是xlDialogEditColor
的参数 - color_num,red_value,green_value,blue_value