Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-21-2023, 08:45 AM
ctviggen ctviggen is offline Working with styled material instead of text Windows 10 Working with styled material instead of text Office 2016
Advanced Beginner
Working with styled material instead of text
 
Join Date: Feb 2021
Posts: 54
ctviggen is on a distinguished road
Default Working with styled material instead of text

I have been manipulating text instead of styled material (not sure what to call it, but could have equations, etc.). My code does this, where I copy the "original part" having certain styles and in one part of the document, paste (as text) it into a different part of the document with a different style, and operate on it. Think of the "original part" as being like a numbered list with additional paragraphs. The other part lists "examples" of what is in the numbered list.



Original part:

Style1 1. Text
Style2 para1;
Style2 para2.
Style2 (blank)
Style1 2. Text that refers to 1
Style2 para3;
Style2 para4.
Style2 (blank)


Inserted and modified material:

Style3 Example of 1. Text; para1; para2.
Style3 Example of 2. Text that refers to 1; para3; para4.

Some of the code looks like this:

Code:
    
    ' oRng is used to select the range of what is being pasted.
    Set oRng = Selection.Range
       
    ' The next line was to keep numbered lines, but it does not work
    ' Options.PasteOptionKeepBulletsAndNumbers = True
    ' Paste in with numbers kept (first line below)
    oRng.ListFormat.ConvertNumbersToText wdNumberParagraph
     oRng.PasteSpecial DataType:=wdPasteText
    <perform operations to format into smaller paragraphs>
As you can see, I had an issue with copying the numbered styles ("Style1" above).

However, this works (for the numbering too) perfectly if you have nothing but text in the original part.

If you have equations, or elements that are not text, it does not copy the equations/whatever is not text and other things happen. I would like to keep those equations and non-text elements.

Can I paste in styled material, operate on it, convert it to Style3 (the style that's used where I paste this)? If so, what code could I use? If not, how would I attempt to do this?

Thanks for any help.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying custom-styled text from the document body in the left margin Nebulous Word 3 11-25-2019 01:06 PM
Working with styled material instead of text Conversion of Columnwise Bill of Material into Rowwise Bill of Material using Excel Macro VBA mpapreja Excel Programming 4 05-21-2018 05:35 AM
TOC and document contains figures and table captions and everything that is not "normal" text styled ki_ha1984 Word 5 06-21-2017 07:25 AM
Working with styled material instead of text How to create single graph figures with multiple graphs inbedded - Taguchi styled analysis Esaylikepie Excel 6 10-24-2016 06:37 AM
Selecting styled text Caroline Word 5 02-15-2011 12:55 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:09 PM.


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