#1
|
|||
|
|||
Bolding in script
I'm sure this has been covered previously, so I do apologize. I did search, but couldnt find what I was looking for.
I've built a script that will place text in a form when an option button is chosen. I want to have the numbers for each paragraph bolded and not the text. I know how to bold the entire paragraph, but not just some. Ex: Currently 10.2.3 - By clicking on the form name, form description or form settings link from the New Form or Edit Form screen, you will activate the form settings interface. The form settings interface consists of three tabs. Each tab consists of options and settings for the form. 10.2.4 - You may select to either use a text based button or an image button. If you would like to use text for a button simply select Text and type in what you would like to appear as the button text. To use an image, select Image and enter the full path to the image you would like to use for the submit button. Need it to be 10.2.3 - By clicking on the form name, form description or form settings link from the New Form or Edit Form screen, you will activate the form settings interface. The form settings interface consists of three tabs. Each tab consists of options and settings for the form. 10.2.4 - You may select to either use a text based button or an image button. If you would like to use text for a button simply select Text and type in what you would like to appear as the button text. To use an image, select Image and enter the full path to the image you would like to use for the submit button. PHP Code:
|
#2
|
||||
|
||||
If these are multi-level list #s inserted by Word, you can't reference them that way - you need to change the numbering format. If they are not multi-level list #s inserted by Word, they probably should be changed to them (makes document maintenance much easier), but you can change all of them in one go via a wildcard Find/Replace, where:
Find = <[0-9]@.[0-9]@.[0-9]@> Replace = ^& and setting the replacement font format to Bold.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Quote:
How would I go about adding a find and replace in my script? |
#4
|
||||
|
||||
You could use the macro recorder to record such a Find/Replace, then add the relevant portions of the recorded code to your existing sub. There are also plenty of posts in this forum showing the use of Find/Replace in macros.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Thanks! Ill do a quick search on here.
|
#6
|
||||
|
||||
You don't need to bother with a search and replace if you make use of the selection.expand method. For instance, you could add the following in front of the End If line
Code:
Dim oPar As Paragraph For Each oPar In oRng.Paragraphs oPar.Range.Select Selection.Collapse Direction:=wdCollapseStart Selection.Extend " " Selection.Font.Bold = True Next oPar |
#7
|
||||
|
||||
Quote:
Code:
Dim oPar As Paragraph For Each oPar In oRng.Paragraphs With oPar.Range .Collapse Direction:=wdCollapseStart .MoveEndUntil " ", wdForward .Font.Bold = True End With Next oPar
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#8
|
||||
|
||||
Nice one Paul. That is what I was looking for before I reverted to Selections.
|
#9
|
|||
|
|||
I have a similar question:
I have a lot of test questions to edit, an example of which is: 1. Everyday items, such as umbrellas or shoes, can become ........ if they were once owned by a celebrity. The umbrellas used by 'The Beatles' in their film 'Help' are worth a small fortune now. A) useful B) practical C) countless D) infinite E) valuable What I need to do is that I need to edit all of the questions so that they become like the example above: the question is bold and the options are not. I wish there were a macro to find "A)" and then automatically make the line bold. I hope I was able to make it clear. |
#10
|
||||
|
||||
Perhaps a macro like this would work if the styles were formatted correctly.
Code:
Dim oPar As Paragraph For Each oPar In ActiveDocument.Paragraphs If Left(oPar.Range.Text,2) = "A)" then oPar.Range.Style = "Normal Indent" Else oPar.Range.Style = "Normal" End if Next
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#11
|
|||
|
|||
Thanks
Thanks for your reply. In the meantime, I tried and found sth like this and it works like charm for me so far:
Code:
Sub Makro5() Selection.Find.ClearFormatting With Selection.Find .Text = "A)" .Forward = True '.Wrap = wdFindContinue .Format = False .MatchCase = True .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute If Selection.Find.Found = True Then Selection.MoveUp Unit:=wdParagraph, Count:=3, Extend:=wdExtend Selection.Font.Bold = wdToggle Selection.MoveDown Unit:=wdParagraph, Count:=2 End If End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help with VBA script | nsyrax | Word VBA | 1 | 01-18-2014 03:38 AM |
Outlook Script Help | TheInfinetGroup | Outlook | 1 | 03-02-2013 07:43 AM |
Add Shared Calendar using script | Antros | Outlook | 0 | 03-15-2012 01:01 PM |
Script Doesn't works on other machine | ravininave | Word | 1 | 01-05-2011 01:45 PM |
[ask] about VB Script + Ms. Project | anak_baru | Project | 2 | 03-10-2009 01:42 AM |