首页 技术 正文
技术 2022年11月12日
0 收藏 336 点赞 3,554 浏览 3031 个字
Sub setname()
Dim I As Integer
Dim pspname As String
Dim pspnumber As String
Dim path As String
Dim srcPath As String
Dim srcPath2 As String Dim wordApp As Object
Dim wordDoc As Object
Dim wordArange As Object
Dim wordSelection As Object
Dim ReplaceSign As Boolean Dim Search1 As String
Dim Search2 As String
Dim docPrefix As String
Dim docSuffix As String
Dim rangSize As Integer 'docPrefix = "-PSP"
'docSuffix = "采购规格书.doc"
'Search1 = "电线"
'Search2 = "6000397-PSP"
'rangSize = 200 docPrefix = "-TST"
docSuffix = "入厂检验规格书.doc"
Search1 = "高压电源"
Search2 = "6000391-TST"
rangSize = 1100 For I = To
srcPath = "C:\cygwin\tmp\BOM\tst.doc"
path = "D:\bom\" & ActiveSheet.Cells(I, ) & "-" & ActiveSheet.Cells(I, )
srcPath2 = path & "\aa.doc"
pspname = path & "\" & ActiveSheet.Cells(I, ) & docPrefix & " " & ActiveSheet.Cells(I, ) & docSuffix
pspnumber = ActiveSheet.Cells(I, ) & docPrefix
MkDir (path)
FileCopy srcPath, srcPath2
Name srcPath2 As pspname Set wordApp = CreateObject("Word.Application") '建立WORD实例
wordApp.Visible = False '屏蔽WORD实例窗体
Set wordDoc = wordApp.Documents.Open(pspname) '打开文件并赋予文件实例
Set wordSelection = wordApp.Selection '定位文件实例
Set wordArange = wordApp.ActiveDocument.Range(, rangSize) '指定文件编辑位置
wordArange.Select '激活编辑位置 Do
ReplaceSign = wordArange.Find.Execute(Search1, True, , , , , wdReplaceAll, wdFindContinue, , ActiveSheet.Cells(I, ), True)
Loop Until ReplaceSign = False Dim rngStory As Object
Dim lngJunk As Long
For Each rngStory In wordDoc.StoryRanges
Do
ReplaceSign = rngStory.Find.Execute(Search2, True, , , , , wdReplaceAll, wdFindContinue, , pspnumber, True)
Set rngStory = rngStory.NextStoryRange
Loop Until rngStory Is Nothing
Next wordDoc.Save
wordDoc.Close True
wordApp.Quit
Next I
End Sub
Sub setname()
Dim I As Integer
Dim pspname As String
Dim pspnumber As String
Dim path As String
Dim srcPath As String
Dim srcPath2 As String Dim wordApp As Object
Dim wordDoc As Object
Dim wordArange As Object
Dim wordSelection As Object
Dim ReplaceSign As Boolean Dim Search1 As String
Dim Search2 As String
Dim docPrefix As String
Dim docSuffix As String
Dim rangSize As Integer 'docPrefix = "-PSP"
'docSuffix = "采购规格书.doc"
'Search1 = "电线"
'Search2 = "6000397-PSP"
'rangSize = 200 docPrefix = "-TST"
docSuffix = "-V1.0.doc"
Search1 = "高压电源"
Search2 = "6000393-TST"
rangSize = For I = To
srcPath = "C:\cygwin\tmp\BOM\tst14.doc"
path = "D:\bom\" & ActiveSheet.Cells(I, ) & "-" & ActiveSheet.Cells(I, )
srcPath2 = path & "\aa.doc"
'pspname = path & "\" & ActiveSheet.Cells(I, 3) & docPrefix & " " & ActiveSheet.Cells(I, 4) & docSuffix
pspname = path & "\" & ActiveSheet.Cells(I, ) & docPrefix & docSuffix
pspnumber = ActiveSheet.Cells(I, ) & docPrefix
MkDir (path)
FileCopy srcPath, srcPath2
Name srcPath2 As pspname Set wordApp = CreateObject("Word.Application") '建立WORD实例
wordApp.Visible = False '屏蔽WORD实例窗体
Set wordDoc = wordApp.Documents.Open(pspname) '打开文件并赋予文件实例
'Set wordSelection = wordApp.Selection '定位文件实例
'Set wordArange = wordApp.ActiveDocument.Range(0, rangSize) '指定文件编辑位置
'wordArange.Select '激活编辑位置 'Do
' ReplaceSign = wordArange.Find.Execute(Search1, True, , , , , wdReplaceAll, wdFindContinue, , ActiveSheet.Cells(I, 4), True)
'Loop Until ReplaceSign = False Dim rngStory As Object
Dim lngJunk As Long
For Each rngStory In wordDoc.StoryRanges
Do
ReplaceSign = rngStory.Find.Execute(Search2, True, , , , , wdReplaceAll, wdFindContinue, , pspnumber, True)
Set rngStory = rngStory.NextStoryRange
Loop Until rngStory Is Nothing
Next wordDoc.Save
wordDoc.Close True
wordApp.Quit
Next I
End Sub
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,489
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,904
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,737
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,490
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,128
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,290