Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将日期mm/dd/yyyy转换为mm.dd.yyyy word vba_Vba_Ms Word - Fatal编程技术网

将日期mm/dd/yyyy转换为mm.dd.yyyy word vba

将日期mm/dd/yyyy转换为mm.dd.yyyy word vba,vba,ms-word,Vba,Ms Word,我有以下日期 2018年2月12日 2/13/2018 2018年2月14日 我需要将上述日期转换为2018年2月12日、2018年2月13日、2018年2月14日,这些日期应加下划线。此代码段将以所需格式将日期插入光标位置,并插入尾随空格 Dim d As String d = "7/25/2011" With Selection .Font.Underline = wdNone ' next text will not be underlined .T

我有以下日期

2018年2月12日 2/13/2018 2018年2月14日


我需要将上述日期转换为2018年2月12日、2018年2月13日、2018年2月14日,这些日期应加下划线。

此代码段将以所需格式将日期插入光标位置,并插入尾随空格

Dim d As String

d = "7/25/2011"
With Selection
    .Font.Underline = wdNone            ' next text will not be underlined
    .TypeText " "                       ' or any separator that will follow the date
    .Collapse                           ' remove selection
    .Start = .Start - 1                 ' set cursor before the separator
    .Collapse                           ' remove selection
    .Font.Underline = wdUnderlineSingle ' next text will be underlined
    .TypeText Format(d, "dd.mm.yyyy")
    .Collapse                ' remove selection and leave the cursor right after the date
End With

你甚至不需要一个宏来完成这项工作-它可以通过一个通配符Find/Replace来完成所有日期,而无需选择任何内容。。。