![]() |
#1
|
|||
|
|||
![]()
Hello!
I have raw text in a .txt file that I am hoping to format using VBA. I haven't touched this stuff in over a decade so I am struggling very much and am looking for some pointers! My raw text looks something like this: Code:
@ALB = <Text that needs to be bolded> @TRI = <Text that needs to be Italicized> @QIU = <Text that needs to be Underlined> @ALB = <Text that needs to be bolded> @ALB = <Text that needs to be bolded> @FSF = <Text that needs Font change> After the text has been appropriately formatted, the code will also need to delete the tag portion (ie. "@ALB = ") so that only the formatted text remains, but I haven't gotten this far with my code. Can you please let me know if I am on the right track? My code was working but began giving errors as my evening progressed and I'm currently getting error 5834. Code:
Sub TextChanger() Application.ScreenUpdating = False Dim StrFind As String, StrStyle As String, i As Long StrFind = "ALB,TRI,QIU,FSF" StrStyle = "ALB,TRI,QIU,FSF" With ActiveDocument.Range.Find .ClearFormatting .Replacement.ClearFormatting .Forward = True .Format = True .Wrap = wdFindContinue .MatchWildcards = True For i = 0 To UBound(Split(StrFind, ",")) .Text = "@" & Split(StrFind, ",")(i) & " = " & "[A-Za-z]*$" .Replacement.Style = Split(StrStyle, ",")(i) .Execute Replace:=wdReplaceAll Next i End With Application.ScreenUpdating = True End Sub ![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Format cell and add a comment based on another tab | Catluvr | Excel Programming | 8 | 08-03-2018 09:54 AM |
![]() |
dmcgettigan | Word VBA | 1 | 02-27-2017 08:50 PM |
![]() |
Rtowey | Excel | 1 | 07-21-2015 06:05 AM |