#1
|
|||
|
|||
Deleting styles but keep text's format
Hello everyone, I have two macros. The first one copies text from Word to Excel based on an Excel list, while the second one adds hyperlinks according to an Excel file. Recently, I encountered an issue where the text I want the macro to copy has different styles. E.g.: Selection.Style = ActiveDocument.Styles("ABCF2")" However, this limitation prevents the macro from copying text, even though I already added the following code to inform the macro to identify and copy them: With Selection.Find .Font.Name = "Times New Roman" .Font.Size = 14 .Font.Underline = 0 .Font.Color = wdColorBlack .MatchWildcards = True To address this problem, I manually applied the same font name to the text, which allowed the macro to recognize and copy it. I would greatly appreciate any suggestions or solutions to overcome this challenge. Thank you in advance. |
#2
|
||||
|
||||
Your selection.find is very specific. If the text is being NOT found then one of those parameters mustn't be being met.
If you want someone to advise why your macro isn't finding text then you would need to post a sample document.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Quote:
Yes. But my document is a confidential one. That's why I cannot upload it here. I struggled it for several months. I will try my best to solve it. Thank you for your reply. |
#4
|
||||
|
||||
In that case, you should remove the conditions one at a time to figure out which one is causing the find to skip.
I note you didn't include a .ClearFormatting first so there may be some carryover sticky setting in your find dialog that tripping you up.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Deleting all text from a slide pack without deleting the formatting | redordead2389 | PowerPoint | 0 | 05-31-2023 06:50 AM |
Format text between two styles | Bikram | Word VBA | 4 | 08-08-2021 11:39 PM |
Deleting styles in Word2016-32 bit version | kae0088 | Word VBA | 8 | 12-07-2020 11:19 AM |
Using Styles in Templates to help format text - Importing and working with Templates | daithy | Word | 2 | 01-03-2020 05:06 PM |
Problem with using Styles to format text. | cummins | Word | 3 | 08-16-2012 05:34 AM |