如何将以下代码 按固定区域字段另存为 且 根据 固定区域字段做文件名 把目录改为母文件目录
Sub BC()
'
' wenhui Macro
' 宏在 2013/6/1 由 Administrator 创建
'
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oNewDoc As Word.Document
Dim oRange As Word.Range
Dim lCurrentStart As Long
Dim lCurrentEnd As Long
Dim lDocumentEnd As Long
Dim lOutputCount As Long
lOutputCount = 0
Set oWord = GetObject(, "Word.Application")
Set oDoc = ActiveDocument
oDoc.Select
lCurrentStart = oWord.Selection.Start
lCurrentEnd = lCurrentStart
lDocumentEnd = oWord.Selection.End
oWord.Selection.Collapse wdCollapseStart
Do While (lCurrentEnd < lDocumentEnd)
oWord.Browser.Target = wdBrowsePage
oWord.Browser.Next
lCurrentEnd = oWord.Selection.End
If (lCurrentStart = lCurrentEnd) Then
lCurrentEnd = lDocumentEnd
End If
Set oRange = oDoc.Range(lCurrentStart, lCurrentEnd)
Set oNewDoc = oWord.Documents.Add
oRange.Copy
oNewDoc.Range(0, 0).Paste
lOutputCount = lOutputCount + 1
oNewDoc.SaveAs FileName:="d:\" & lOutputCount & ".doc"
oNewDoc.Close
lCurrentStart = lCurrentEnd
Loop
End Sub
请问你的问题解决了么,我碰到和你一样的问题!
大家好,在word中如何利用VBA提取页眉,然后输出以页眉命名的word文件呀?