|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 宏1()
Dim wdapp As Object
Dim wddocument, range2
Dim mypath$, myname$
Dim wdRng As Object, wd As Object
Dim pos1%, pos2%, pos3%, pos4% '定义找字段首位位置
Set wddocument = ActiveDocument
Set wdRng = wddocument.Range
wdRng.Find.Execute ("/ MDO")
pos1 = wdRng.End
Set wdRng = wddocument.Range
wdRng.Find.Execute ("B.ROB: IFO=")
pos2 = wdRng.Start
wddocument.Range(pos1, pos2).Copy '选找两字段间内容
Set wdRng = wddocument.Range
wdRng.Find.Execute ("/ Consumed:")
pos3 = wdRng.End
Set wdRng = wddocument.Range
wdRng.Find.Execute ("mt")
pos4 = wdRng.Start
wddocument.Range(pos3, pos4).Copy '选找两字段间内容
Application.DisplayAlerts = False
Set range2 = Documents.Open(ActiveDocument.Path & "\管理公司午报.docx")
Set wd = range2.Range
wd.Find.Execute ("HSFO")
pos1 = wd.End
Set wd = range2.Range
wd.Find.Execute ("/LSFO")
pos2 = wd.Start
range2.Range(pos1, pos2).PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis)
Set wd = range2.Range
wd.Find.Execute ("FW Daily Consumed")
pos3 = wd.End
Set wd = range2.Range
wd.Find.Execute ("/LSFO")
pos4 = wd.Start
range2.Range(pos3, pos4).PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis)
range2.Close True
End Sub
|
|