|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub tihuan()
- Dim wdapp As Object, wd As Object
- Dim i As Integer
- Dim it As String
- Set wdapp = CreateObject("word.application")
- wdapp.Visible = True
- Application.DisplayAlerts = False
- Application.CutCopyMode = False
- Application.ScreenUpdating = False
- With Application.FileDialog(msoFileDialogFilePicker)
- .Title = "请选择模版文件"
- .AllowMultiSelect = False
- .Filters.Clear
- .Filters.Add "Word Files", "*.doc;*.docx"
- If .Show = 0 Then
- Exit Sub
- End If
- it = .SelectedItems(1)
- End With
- Set wd = wdapp.documents.Open(it)
- 'Set wd = GetObject(it)
- 'For i = 3 To ActiveSheet.Cells(65536, 1).End(xlUp).Row
- With wd.Content.Find
- .ClearFormatting
- .Replacement.ClearFormatting
- .Text = "设计单位"
- .Replacement.Text = "aaaaaaaaaaaaaa"
- .Execute Replace:=2 'wdReplaceAll
- .Forward = True
- .Wrap = 1 'wdFindContinue
- .Format = False
- .MatchCase = False
- .MatchWholeWord = False
- .MatchByte = True
- .MatchWildcards = False
- .MatchSoundsLike = False
- .MatchAllWordForms = False
- End With
- 'Next i
- wd.SaveAs Filename:=ThisWorkbook.Path & "\" & ActiveSheet.Cells(1, 1)
- wd.Close True
- wdapp.Quit
- Set wd = Nothing
- Set wdapp = Nothing
- Application.DisplayAlerts = True
- Application.CutCopyMode = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|