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
-
Thunderbird release notes for 128 esr have disappeared
by
EricB
1 hour, 37 minutes ago -
CISA mutes own website, shifts routine cyber alerts to X, RSS, email
by
Nibbled To Death By Ducks
2 hours, 5 minutes ago -
Apple releases 18.5
by
Susan Bradley
2 hours, 24 minutes ago -
Fedora Linux 40 will go end of life for updates and support on 2025-05-13.
by
Alex5723
3 hours, 31 minutes ago -
How a new type of AI is helping police skirt facial recognition bans
by
Alex5723
4 hours, 9 minutes ago -
Windows 7 ISO /Windows 10 ISO
by
ECWS
11 hours, 5 minutes ago -
No HP software folders
by
fpefpe
11 hours, 50 minutes ago -
Which antivirus apps and VPNs are the most secure in 2025?
by
B. Livingston
4 hours, 2 minutes ago -
Stay connected anywhere
by
Peter Deegan
17 hours, 13 minutes ago -
Copilot, under the table
by
Will Fastie
8 hours, 26 minutes ago -
The Windows experience
by
Will Fastie
23 hours, 27 minutes ago -
A tale of two operating systems
by
Susan Bradley
14 hours, 23 minutes ago -
Microsoft : Resolving Blue Screen errors in Windows
by
Alex5723
1 day, 4 hours ago -
Where’s the cache today?
by
Up2you2
1 day, 20 hours ago -
Ascension says recent data breach affects over 430,000 patients
by
Nibbled To Death By Ducks
1 day, 12 hours ago -
Nintendo Switch 2 has a remote killing switch
by
Alex5723
13 hours, 12 minutes ago -
Blocking Search (on task bar) from going to web
by
HenryW
1 day, 20 hours ago -
Windows 10: Microsoft 365 Apps will be supported up to Oct. 10 2028
by
Alex5723
2 days, 13 hours ago -
Add or Remove “Ask Copilot” Context Menu in Windows 11 and 10
by
Alex5723
2 days, 13 hours ago -
regarding april update and may update
by
heybengbeng
2 days, 14 hours ago -
MS Passkey
by
pmruzicka
1 day, 16 hours ago -
Can’t make Opera my default browser
by
bmeacham
2 days, 22 hours ago -
*Some settings are managed by your organization
by
rlowe44
2 days, 9 hours ago -
Formatting of “Forward”ed e-mails
by
Scott Mills
2 days, 21 hours ago -
SmartSwitch PC Updates will only be supported through the MS Store Going Forward
by
PL1
3 days, 17 hours ago -
CISA warns of hackers targeting critical oil infrastructure
by
Nibbled To Death By Ducks
4 days, 2 hours ago -
AI slop
by
Susan Bradley
1 day, 20 hours ago -
Chrome : Using AI with Enhanced Protection mode
by
Alex5723
4 days, 3 hours ago -
Two blank icons
by
CR2
1 day, 11 hours ago -
Documents, Pictures, Desktop on OneDrive in Windows 11
by
ThePhoenix
1 day, 13 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.