0
내 요구 사항은 워드 문서의 테이블에서 선택한 셀의 날짜 형식을 변경하고자하는 것입니다. 나는 아래 코드를 시도했다. 단일 날짜를 선택하면 날짜 형식을 변경할 수 있습니다. 그러나 선택한 날짜 형식을 변경할 수는 없습니다. 테이블에있는 세포의.날짜 형식을 지정하려면 no를 선택하십시오. 테이블의 셀 개수
Sub ConvertDateFormat()
'
' Date formating
'
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
Selection.Text = Format(Selection.Text, "yyyy-MM-dd")
Selection.Collapse wdCollapseEnd
Else ' not a date - end loop
MsgBox ("Invalid Date Format")
End If
End With
Next oCl
lbl_Exit:
Exit Sub
End Sub
정말 고마워요. 그것은 작동합니다. –