Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-16-2016, 02:47 AM
PRA007's Avatar
PRA007 PRA007 is offline How to give multiple styles while inserting string Windows 7 64bit How to give multiple styles while inserting string Office 2010 32bit
Competent Performer
How to give multiple styles while inserting string
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default How to give multiple styles while inserting string

While parsing I get three different string and I want to format them as below.

.Text = "Title" (style = heading 2) & vbcr


.text = strtxtT(style = heading 3) & vbcr
.text = StrtxtD(style = normal, bold = False)
.text = strtxtN(style = normal, bold = True)
Reply With Quote
  #2  
Old 01-16-2016, 04:03 AM
macropod's Avatar
macropod macropod is offline How to give multiple styles while inserting string Windows 7 64bit How to give multiple styles while inserting string Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I've already provided you with code to format parts of a string in this thread:
https://www.msofficeforums.com/word-...tion-bold.html
Applying Styles is no different.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-16-2016, 05:13 AM
PRA007's Avatar
PRA007 PRA007 is offline How to give multiple styles while inserting string Windows 7 64bit How to give multiple styles while inserting string Office 2010 32bit
Competent Performer
How to give multiple styles while inserting string
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

Ok. I tried but I think The problem is with paragraphs.

Recorded macro and found that
Code:
.Style = ActiveDocument.Styles("Heading 2")
is the key to success.
Reply With Quote
  #4  
Old 01-16-2016, 01:38 PM
macropod's Avatar
macropod macropod is offline How to give multiple styles while inserting string Windows 7 64bit How to give multiple styles while inserting string Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by PRA007 View Post
Ok. I tried but I think The problem is with paragraphs.

Recorded macro and found that
Code:
.Style = ActiveDocument.Styles("Heading 2")
is the key to success.
What is the problem with paragraphs?

Your code could be reduced to:
Code:
.Style = "Heading 2"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 01-18-2016, 12:00 AM
PRA007's Avatar
PRA007 PRA007 is offline How to give multiple styles while inserting string Windows 7 64bit How to give multiple styles while inserting string Office 2010 32bit
Competent Performer
How to give multiple styles while inserting string
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
What is the problem with paragraphs?
I think because s my code was from the HTML it was having some paragraphs which was disturbing the overall pattern. I split the string with paragraphs and solved the problem.

Quote:
Originally Posted by macropod View Post
Your code could be reduced to:
Code:
.Style = "Heading 2"
Thanks, for suggesting neat code.
Reply With Quote
Reply

Tags
vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to do multiple find and replace in string. PRA007 Word VBA 2 01-06-2016 09:10 PM
Multiple Hyperlink to a single string PRA007 Word VBA 7 11-09-2015 04:29 PM
How to give multiple styles while inserting string Find Multiple Wildcard string and Highlight PRA007 Word VBA 2 10-17-2015 01:07 AM
How do I string together multiple copies of the same template in Office 2011 for Mac? terrymarks Word 1 06-14-2015 10:21 PM
inserting a string of data into an MS Word table??? matto Word VBA 0 07-16-2010 09:35 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:39 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