0
我正在使用下面的代碼來更改日期格式。將此宏用作使用XML的功能區中的下拉選項。但它給「參數不可選」錯誤。編譯錯誤:參數不可選
請幫我在哪裏做錯了。
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
@PankajKumar,你通過了嗎? – user3598756