Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-13-2023, 08:21 PM
syl3786 syl3786 is offline Deleting styles but keep text's format Windows 10 Deleting styles but keep text's format Office 2019
Advanced Beginner
Deleting styles but keep text's format
 
Join Date: Jan 2023
Posts: 78
syl3786 is on a distinguished road
Exclamation 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.
Reply With Quote
  #2  
Old 10-14-2023, 02:52 AM
Guessed's Avatar
Guessed Guessed is offline Deleting styles but keep text's format Windows 10 Deleting styles but keep text's format Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #3  
Old 10-15-2023, 08:47 AM
syl3786 syl3786 is offline Deleting styles but keep text's format Windows 10 Deleting styles but keep text's format Office 2019
Advanced Beginner
Deleting styles but keep text's format
 
Join Date: Jan 2023
Posts: 78
syl3786 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
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.

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.
Reply With Quote
  #4  
Old 10-15-2023, 04:17 PM
Guessed's Avatar
Guessed Guessed is offline Deleting styles but keep text's format Windows 10 Deleting styles but keep text's format Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
Reply



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
Deleting styles but keep text's format Problem with using Styles to format text. cummins Word 3 08-16-2012 05:34 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:13 AM.


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