我使用以下代码更改日期格式。使用此宏作为使用XML的功能区中的下拉选项。但它给出了#34;参数不是可选的"错误。
请在我做错的地方帮忙。
Public Sub ConvertDateFormat1(control As IRibbonControl)
'
' date formating (MM/DD/YYYY)
'
Dim oCl As Word.Cell
Dim oRng As Range
'
' Condition to check the selected data
'
If Selection.Type = wdSelectionIP Or _
Not Selection.Information(wdWithInTable) Then
MsgBox "Select a cell or range of cells before running" _
& " this macro.", , "Nothing Selected"
Exit Sub
End If
For Each oCl In Selection.Cells
Set oRng = oCl.Range
'
'Drop of the end of cell mark
'
oRng.End = oRng.End - 1
With oRng
If IsDate(oRng) Then
oRng.Text = Format(oRng.Text, "MM/DD/YYYY")
Else ' not a date - end loop
MsgBox ("Invalid Date Format")
End If
End With
Next oCl
lbl_Exit:
Exit Sub
End Sub
答案 0 :(得分:0)
根据其签名,您的sub会期望类型为control
的{{1}}参数
但由于它实际上没有使用它,您可能想要删除它:
IRibbonControl