![]() |
|
#1
|
|||
|
|||
|
I have a document that is separated by section breaks. I want to have a macro that will take the current section (where my cursor is) and copy it into a new document.
I'm getting the Run-time error '4605' (This command is not available), which my web research suggests is due to using the .Copy and .PasteAndFormat functions. What I haven't been able to figure out is how to rewrite this without using those functions, however! Code:
Sub CopyCurrentSectionToNewDoc()
currentSection = Selection.Information(wdActiveEndSectionNumber)
With ActiveDocument.Sections(currentSection)
Set Rng = .Range
With Rng
.MoveEnd wdCharacter, -1
.Copy
End With
End With
Set NewDoc = Documents.Add(Template:=ActiveDocument.AttachedTemplate.FullName, Visible:=True)
With NewDoc
' Paste contents into the output document, preserving the formatting
.Range.PasteAndFormat (wdFormatOriginalFormatting)
End With
End Sub
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Prevent header from using StyleRef x when x is not present in current section
|
Firebody | Word | 8 | 11-12-2021 10:53 AM |
| Require VBA to copy value into current field of Internet Explorer | trevorc | Excel Programming | 0 | 01-15-2019 03:17 PM |
| If Cell Blank Copy Data from Above Combine All to Current | ChrisOK | Excel Programming | 2 | 12-18-2017 11:25 PM |
Show current section in status bar
|
Phil H | Word | 2 | 02-02-2016 01:45 PM |
| a macro that can copy data from copy.xls to our current excel macro.xls based on criteria: | udhaya | Excel Programming | 1 | 11-12-2015 10:12 AM |