Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-15-2024, 06:49 AM
syl3786 syl3786 is offline Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Windows 10 Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Office 2019
Advanced Beginner
Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape
 
Join Date: Jan 2023
Posts: 78
syl3786 is on a distinguished road
Default Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape

I'm in need of some assistance regarding Word macros. Specifically, I'm wondering if it's possible to automatically add a transparent, blue line circle shape over specific text using a Word macro. 📝💻



I've explored some options, but I'm not quite sure how to approach this task. That's why I'm reaching out to this knowledgeable community for guidance and expertise.

If you have experience with Word macros or VBA (Visual Basic for Applications), I would greatly appreciate your insights. Is it feasible to achieve this goal using a macro? Are there any specific techniques or code snippets you could suggest?

My intention is to have the macro identify the specific text within a Word document and automatically overlay a transparent, blue line circle shape on top of it (see attached document) Expected Result.docx

Your assistance would be immensely valuable, and I'm eager to learn from your expertise. Thank you in advance for your support! 😊💙

My code drafted:

Code:
Sub AddCircleShape()
    Dim rng As Range
    Dim shape As Shape
    
    Set rng = ActiveDocument.Content
    rng.Find.Text = "YOUR_SPECIFIC_TEXT"
    rng.Find.Execute
    
    If rng.Find.Found Then
        Set shape = ActiveDocument.Shapes.AddShape(msoShapeOval, rng.Information(wdHorizontalPositionRelativeToPage), rng.Information(wdVerticalPositionRelativeToPage), rng.Information(wdShapeSizeWidth), rng.Information(wdShapeSizeHeight))
        With shape
            .Fill.Transparency = 0.5 ' Adjust the transparency value as desired
            .Fill.ForeColor.RGB = RGB(0, 0, 255) ' Set the color to blue; modify RGB values if needed
            .Line.Visible = msoTrue
        End With
    End If
End Sub
Reply With Quote
  #2  
Old 01-17-2024, 04:31 AM
vivka vivka is offline Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Windows 7 64bit Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

Hi! Try this:
Code:
Sub Find_Str_Add_Shape()
'In the selection, find the inputboxed string & add a transparent
'blue oval shape over it.
    
Dim rng As range
Dim stri As String
Dim shp As shape
    
    Set rng = selection.range
    stri = InputBox("Enter the string to find:")
    rng.Find.text = stri
    rng.Find.Execute
    
    If rng.Find.found Then
        rng.Select
        Set shp = ActiveDocument.Shapes.AddShape(msoShapeOval, _
        selection.Information(wdHorizontalPositionRelativeToPage), _
        selection.Information(wdVerticalPositionRelativeToPage), _
        20, 16)
        With shp
            .Fill.Transparency = 1 'Full transparency
            .Line.ForeColor.RGB = RGB(0, 0, 255) 'Blue color
            .Line.Visible = msoTrue
        End With
    End If
End Sub
You may change 'Set rng = selection.range' to 'Set rng = ActiveDocument.range'.
Reply With Quote
  #3  
Old 01-19-2024, 07:58 AM
syl3786 syl3786 is offline Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Windows 10 Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Office 2019
Advanced Beginner
Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape
 
Join Date: Jan 2023
Posts: 78
syl3786 is on a distinguished road
Default

Quote:
Originally Posted by vivka View Post
Hi! Try this:
Code:
Sub Find_Str_Add_Shape()
'In the selection, find the inputboxed string & add a transparent
'blue oval shape over it.
    
Dim rng As range
Dim stri As String
Dim shp As shape
    
    Set rng = selection.range
    stri = InputBox("Enter the string to find:")
    rng.Find.text = stri
    rng.Find.Execute
    
    If rng.Find.found Then
        rng.Select
        Set shp = ActiveDocument.Shapes.AddShape(msoShapeOval, _
        selection.Information(wdHorizontalPositionRelativeToPage), _
        selection.Information(wdVerticalPositionRelativeToPage), _
        20, 16)
        With shp
            .Fill.Transparency = 1 'Full transparency
            .Line.ForeColor.RGB = RGB(0, 0, 255) 'Blue color
            .Line.Visible = msoTrue
        End With
    End If
End Sub
You may change 'Set rng = selection.range' to 'Set rng = ActiveDocument.range'.
Hi Vivka, thank you so much for your assistance - it really helped me!

I apologize for my delayed response, but I've been feeling ill lately. Thankfully, I'm on the mend and am feeling about 80% better. I hope you're doing well too! I have a question that might sound a bit silly, but I was wondering if it's possible to set the width of a line?
Reply With Quote
  #4  
Old 01-19-2024, 11:16 AM
vivka vivka is offline Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Windows 7 64bit Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

Hi, syl3786! 1. You are welcome! 2. Get well as soon as possible! 3. Thank you for your wishing me good health! 4. Add
Code:
.Line.Weight = 3
after
Code:
.Line.ForeColor.RGB = RGB(255, 0, 0)
You may change '3' to any other value.
Reply With Quote
  #5  
Old 01-21-2024, 03:11 AM
syl3786 syl3786 is offline Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Windows 10 Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Office 2019
Advanced Beginner
Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape
 
Join Date: Jan 2023
Posts: 78
syl3786 is on a distinguished road
Default

Quote:
Originally Posted by vivka View Post
Hi, syl3786! 1. You are welcome! 2. Get well as soon as possible! 3. Thank you for your wishing me good health! 4. Add
Code:
.Line.Weight = 3
after
Code:
.Line.ForeColor.RGB = RGB(255, 0, 0)
You may change '3' to any other value.

Many thanks for your help!
Reply With Quote
  #6  
Old 01-21-2024, 03:41 AM
vivka vivka is offline Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Windows 7 64bit Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

You are welcome!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Potential Clashes in Macros - Seeking Assistance yanyan9896 Word VBA 2 10-09-2023 04:59 AM
Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape vba code in word to delete line having inline shape anand Word VBA 7 06-18-2015 10:02 PM
Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape remove blue line dogbite Word 1 12-17-2014 06:23 AM
Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape How to write Text above the Shape Line in Ms Word 2010 tahakirmani Word 2 11-28-2013 05:33 PM
Seeking Assistance with Word Macro to Add Transparent, Blue Line Circle Shape Round Blue Circle Keeps Flashing and Circling randyflycaster Word 5 09-14-2011 07:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:16 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