Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-11-2023, 05:59 AM
shortbred shortbred is offline Select where to insert new image Windows 10 Select where to insert new image Office 2021
Novice
Select where to insert new image
 
Join Date: Oct 2023
Posts: 4
shortbred is on a distinguished road
Default Select where to insert new image

Hi all,

This is probably really basic, I have been trawling through information trying to find the answer with no luck. Basically I have an arduous task of changing some text and a picture on over 250 documents. The code I have is as below (obviously text and file path changed)

The top of it works fine, the text replaces, the old picture gets deleted (well replaced with " "). It's the bottom bit as it will pull in the new image at whatever location the cursor is at when the file opens. I was it to be where the old one is, that is half the reason I replaced the photo with " " thinking maybe I can get the cursor to go to " " and then pull the image in but I can't even find how to do that, I'm sure there's a much easier way than the roundabout way I am trying anyway, so any help will be gratefully apricated.



Sub SimpleReplace()


Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "ABC"
.Replacement.Text = "XYZ"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False


.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False

End With
Selection.Find.Execute Replace:=wdReplaceAll


Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^g"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False

End With
Selection.Find.Execute Replace:=wdReplaceAll


Selection.InlineShapes.AddPicture FileName:= _
"C:\FILE PATH", LinkToFile:=False, _
SaveWithDocument:=True

End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Image and Move to Front Pestomania Word VBA 1 12-24-2020 09:07 AM
Word 2007-cannot select or copy image calvin-c Word 2 01-05-2017 02:26 PM
ComboBox : select image to insert in Sheet1 smallxyz Excel Programming 0 02-07-2016 05:41 PM
Select where to insert new image Select an entire line (to insert one) Officer_Bierschnitt Excel Programming 3 11-06-2015 03:05 AM
Background image vs. insert image lilaria PowerPoint 0 04-18-2011 08:45 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft