Reply to topic  [ 6 posts ] 
macro: preserve some character attributes, but add italics 
Author Message

Joined: 2011-01-12 05:32:38
Posts: 256
I want to change [this] to this, or [this] to this, or [this] to this, i.e. text with brackets to italicized text. However, sometimes the target text in brackets already has bold, underline or such applied. All I want is to add italics. I'm using the PowerFind Pro find and replace formula in the attached screenshot. However, if the text has other attributes applied, it removed them and adds back italics only. How can I get want I need? Do I need to do separate find/replace functions for differing text, i.e. one for text already in bold, one for text already in bold & underline, one for text that has no attributes applied yet, etc.?


Attachments:
imprecise find-replace_deletes formatting.png
imprecise find-replace_deletes formatting.png [ 28.09 KiB | Viewed 3702 times ]
2012-11-28 06:35:40
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
I would use a macro for this. Then rather than do Find and Replace, I would do this:
Code:
Find All ...
Italic

So I'd just use the Find capability to Find things and then apply the formatting "by hand" (so to speak).
Hope this helps.

_________________
philip


2012-11-28 07:32:21
Profile

Joined: 2011-01-12 05:32:38
Posts: 256
Philip,

I guess I don't know fully the difference between Find and Replace and a macro. I was just assuming a macro was a Find and Replace expression that was saved and run as a macro. Maybe you can help me out as to what you meant.

Attached is a macro I made to do this. For some reason it doesn't work, though. I thought I followed your examples. Would you be willing to help me out?

Thanks!


Attachments:
EC-brackets to italics.nwm [823 Bytes]
Downloaded 225 times
2012-11-28 20:44:21
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
Hi I have fixed your macro.(Keeping my fingers crossed.) If you do it right then you don't need three Find/Replace statements. Your last one will suffice.

Attachment:
EC-brackets_to_italics_(simple).nwm [3.09 KiB]
Downloaded 245 times


What does "do it right mean"? Well the attribute sensitive find/replace pays attention to the attributes. All the attributes. So once you paste the statement into a file it takes on other attributes (paragraph style, for example), and then it stops working. The solution for such cases is to use the "Remove Attributes and Styles" command, and then add back just the attributes you want.

to be continued…

_________________
philip


Last edited by phspaelti on 2012-11-29 05:13:39, edited 1 time in total.



2012-11-29 05:07:28
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
Anyhow I hate fussing with the attributes so I suggested a second method.

Attachment:
EC-brackets_to_italics_(2_step).nwm [3.14 KiB]
Downloaded 222 times


As I described above, you can use Find/Replace to select things, and then apply the styles you want. As long as the Find part doesn't care about styles, this works, a bit more "reliably".

A macro can contain more than just a list of Find/Replace statements. You can add any menu commands (just type them exactly as the menu name says), and then there is a whole macro language if you want to get really elaborate.

Anyhow good luck with your macro writing. :wink:

_________________
philip


2012-11-29 05:12:22
Profile

Joined: 2011-01-12 05:32:38
Posts: 256
Thank you very much for all your help and tutoring!


2012-11-29 07:04:45
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: Bing [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software