Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 02-04-2024, 08:31 AM
ctviggen ctviggen is offline Add text to beginning of new document opened from original Word document, with styles Windows 10 Add text to beginning of new document opened from original Word document, with styles Office 2016
Advanced Beginner
Add text to beginning of new document opened from original Word document, with styles
 
Join Date: Feb 2021
Posts: 54
ctviggen is on a distinguished road
Default

I figured it out, using a brute force method. I first re-ran the code by Chat GPT, but that was wrong. So, I looked at other code of mine and just went line by line through this, changing coding as necessary and running 10+ times, until I got what I wanted. Not pretty, but works.


Code:
newDoc.paragraphs(1).Range.InsertBefore Text:="Para1" & vbCr & vbCr
    newDoc.paragraphs(2).Style = "StyleB"
    newDoc.paragraphs(2).Range.InsertAfter Text:="Para2" & vbCr & vbCr
    newDoc.paragraphs(4).Style = "StyleB"
    newDoc.paragraphs(4).Range.InsertAfter Text:="Para3" & vbCr & vbCr
    newDoc.paragraphs(6).Style = "StyleB"
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Add text to beginning of new document opened from original Word document, with styles Get path of newly opened word document MANOHAR Word 2 04-12-2017 06:07 AM
Hyperlinks that Do Not Exist in the Original Word Document Appearing in the PDF Document diarrheaofthewprocessor Word 11 01-24-2017 01:52 PM
Single step Word Styles from Source Document through entire Destination document? xbliss Word 6 08-27-2016 09:36 PM
Word 2013 - When deleting section breaks, cursor jumps to beginning of document ranholmom66 Word 3 07-01-2016 06:01 AM
Add text to beginning of new document opened from original Word document, with styles Lost word document now opened in unknown Danwordman Word 2 07-07-2015 05:03 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:42 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft