In my macro, I copied some text, and I want to open a new document and past it/ manipulate it. Can that be done?
I was able to record it as such, but when I ran the macro, all of the actions took place in the original document.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Opening a blank Doc. (Word XP)
Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Opening a blank Doc. (Word XP)
- This topic has 9 replies, 3 voices, and was last updated 22 years, 1 month ago.
AuthorTopicWSmusical1
AskWoody LoungerApril 15, 2003 at 3:19 pm #386127Viewing 0 reply threadsAuthorReplies-
WSKevin
AskWoody Lounger -
WSmusical1
AskWoody LoungerApril 15, 2003 at 4:30 pm #668733Here’s the code. I recorded it in 2000. ( I don’t think it should make a difference on this topic)
I recorded most of the script and went back in to start commenting the sections. Fron what I can read in the code, it didn’t record anything that would have opened a new doc. You’ll see by my comment, where it’s supose to be. – J
Sub RTMCreate4()
‘
‘ RTMCreate4 Macro
‘ Macro recorded 4/15/2003 by SanBill
‘
Selection.EndKey Unit:=wdStory
With ActiveDocument
.TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
True, UseHeadingStyles:=True, UpperHeadingLevel:=4, _
LowerHeadingLevel:=9, IncludePageNumbers:=False, AddedStyles:= _
“Heading 1,1,Heading 2,2,Heading 3,3”, UseHyperlinks:=True, _
HidePageNumbersInWeb:=True
.TablesOfContents(1).TabLeader = wdTabLeaderDots
.TablesOfContents.Format = wdIndexIndent
End With
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles(“TOC 1”)
Selection.Find.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = “”
.Replacement.Text = “”
.Forward = False
.Wrap = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveDown Unit:=wdParagraph, Count:=2, Extend:=wdExtend
Selection.Fields.Unlink
Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=2, _
NumRows:=20, Format:=wdTableFormatNone, ApplyBorders:=True, ApplyShading _
:=True, ApplyFont:=True, ApplyColor:=True, ApplyHeadingRows:=True, _
ApplyLastRow:=False, ApplyFirstColumn:=True, ApplyLastColumn:=False, _
AutoFit:=True, AutoFitBehavior:=wdAutoFitContent
Selection.MoveLeft Unit:=wdCharacter, Count:=1
End Sub -
WSKevin
AskWoody LoungerApril 15, 2003 at 4:35 pm #668734Hummm. I take that back, the code isn’t much help at this point. A little, I guess.
Here’s some air code (heavy on the CO2) (see Rory, I like it so much I’m using it now!)
Tell us if this is a correct interpretation of your intentions:1. Add a table of contents
2. Select the table of contents using the find method
3. Then copy that selected TOC to the clipboard
4. Create new blank doc.
5. Paste TOC from clipboard into new doc -
WSmusical1
AskWoody Lounger -
WSKevin
AskWoody Lounger -
WSmusical1
AskWoody LoungerApril 15, 2003 at 4:47 pm #668742Select it, Break the link and convert it to a table.
Though, that could be done in the current doc, cut and pasted into the new doc.
Either way, when I open a new doc, the code for such doesn’t record. It picks back up where I paste (supposedly into the new doc)… but it pastes right into the same doc.
-
WSHansV
AskWoody Lounger -
WSmusical1
AskWoody Lounger
-
-
-
-
-
WSmusical1
AskWoody LoungerApril 15, 2003 at 4:39 pm #668735OOOPS! I posted the wrong code… I think it’s similar, but this one at least has comments…
Sub RTMCreate2()
‘
‘ RTMCreate2 Macro
‘ Macro recorded 4/15/2003 by Jody Dyche
‘
‘Go to beginning of document and go to beginning of TOC. Select TOC.
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles(“TOC 1”)
Selection.Find.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = “”
.Replacement.Text = “”
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend‘Replace Existing TOC with 9 level TOC
With ActiveDocument
.TablesOfContents(1).Delete
.TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
True, UseHeadingStyles:=True, UpperHeadingLevel:=4, _
LowerHeadingLevel:=9, IncludePageNumbers:=False, AddedStyles:= _
“Heading 1,1,Heading 2,2,Heading 3,3”, UseHyperlinks:=True, _
HidePageNumbersInWeb:=True
.TablesOfContents(1).TabLeader = wdTabLeaderDots
.TablesOfContents.Format = wdIndexIndent
End With‘Go to beginning of document, Go to TOC, select and copy.
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles(“TOC 1”)
Selection.Find.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = “”
.Replacement.Text = “”
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend
Selection.Copy‘Open New document and paste.
Selection.Paste
Selection.HomeKey Unit:=wdStory
Selection.WholeStory
Selection.Fields.Unlink
Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=2, _
NumRows:=21, Format:=wdTableFormatNone, ApplyBorders:=True, ApplyShading _
:=True, ApplyFont:=True, ApplyColor:=True, ApplyHeadingRows:=True, _
ApplyLastRow:=False, ApplyFirstColumn:=True, ApplyLastColumn:=False, _
AutoFit:=True, AutoFitBehavior:=wdAutoFitFixed
Selection.HomeKey Unit:=wdLine
Selection.MoveRight Unit:=wdCell
Selection.HomeKey Unit:=wdLine
Selection.HomeKey Unit:=wdStory
End Sub
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
3 hours, 18 minutes ago -
Manage your browsing experience with Edge
by
Mary Branscombe
3 hours, 57 minutes ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
10 minutes ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
8 minutes ago -
Apps included with macOS
by
Will Fastie
4 hours ago -
Xfinity home internet
by
MrJimPhelps
8 hours, 49 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
10 hours, 48 minutes ago -
Debian 12.11 released
by
Alex5723
19 hours, 14 minutes ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
22 hours, 56 minutes ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
2 hours, 22 minutes ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
19 hours, 24 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
1 day, 15 hours ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
1 day, 6 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
1 day, 18 hours ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
1 day, 10 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
18 hours, 20 minutes ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
11 hours, 11 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
2 days, 4 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
2 days ago -
Does windows update component store “self heal”?
by
Mike Cross
1 day, 14 hours ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
2 days, 17 hours ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
1 day, 1 hour ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
14 hours, 33 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
2 days, 20 hours ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
2 days, 20 hours ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
2 days, 9 hours ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
3 days, 4 hours ago -
0Patch, where to begin
by
cassel23
2 days, 22 hours ago -
CFPB Quietly Kills Rule to Shield Americans From Data Brokers
by
Alex5723
3 days, 18 hours ago -
89 million Steam account details just got leaked,
by
Alex5723
3 days, 6 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.