我使用vba动态创建命名范围。然后我想导出每个页面中每个命名范围中的单词。例如:命名范围是Page1,Page2,... Page10 ......等。当我尝试导出时,Page1排在第一位,page10排在第二位。如何使它成为page1,page2等...
For intCounter = 1 To wbBook.Names.Count
MsgBox Names(intCounter).name
'If IsNameRefertoSheet(oSht, Names(intCounter)) Then
If Names(intCounter).name Like "Page*" Then
With objDoc
Set rtarget = .Range(.Content.End - 1, .Content.End - 1)
'Insert page break if not first page
If Names(intCounter).name <> "Page1" Then rtarget.InsertBreak Type:=wdPageBreak
'Copy data from named range
Range(wbBook.Names(intCounter)).Copy
Set rtarget = .Range(.Content.End - 1, .Content.End - 1)
rtarget.Paste
End With
End If
'End If
Next intCounter
答案 0 :(得分:0)
一个命题
nbrofpage=10 'set your number of pages
For intcounter = 1 To nbrofpage
With objDoc
Set rtarget = .Range(.Content.End - 1, .Content.End - 1)
'Insert page break if not first page
If intcounter <> 1 Then rtarget.InsertBreak Type:=wdPageBreak
'Copy data from named range
Range("page" & intcounter).Copy
Set rtarget = .Range(.Content.End - 1, .Content.End - 1)
rtarget.Paste
End With
Next intcounter