![]() |
|
![]() |
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
![]()
The code you have posted won't even compile so it won't do anything. What does
September CurrrentRange supposed to mean? Even after you got you declarations straightened out the fundamental error in your ways is using the selection object. You use the selection object to find something, find it and then redefine the selection. It is therefore impossible to find anything else in your very limited selection. Learn to use the range object which leaves the selection alone: Code:
Sub Replace_String_ImageNUOVO() 'A basic Word macro coded by Greg Maxey Dim PixPathandName As String Dim oRng As Range PixPathandName = "J:\APPS\ACCESS\MDB2007\FOTOxOFFERTE\" Set oRng = Selection.Range With oRng.Find .Text = "FOTO_" Do While .Execute() oRng.MoveEnd wdWord, 1 Selection.InlineShapes.AddPicture FileName:=PixPathandName & Trim(oRng.Text) & ".JPG", _ LinkToFile:=False, SaveWithDocument:=True oRng.Collapse wdCollapseEnd Loop End With lbl_Exit: Exit Sub End Sub |
#2
|
|||
|
|||
![]()
First of all thank you very much but i'm sorry i'm not so expert in vba .
I tried to learn the range object but no results. The code you post work fine but I find some problem using it. The macro would replace the variable string text (eg FOTO_Eclipse or FOTO_FORMA3) with the picture with the same name in the same position not at the beginning of the word file Sometimes the file picture inside the directory "J: \ APPS \ ACCESS \ MDB2007 \ FOTOxOFFERTE \" doesn't exist but I should the code continue until the end to replace all the strings text that have the same names of pictures without stopping. Is it possible to do it ? Please help me if you can. Thank you very much Marco Quote:
|
![]() |
Tags |
images, text |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Object Variable or With block variable not set | Raza | Excel Programming | 8 | 01-15-2015 12:19 AM |
Run Time Error '91': Object variable or With block variable not set using Catalogue Mailmerge | Berryblue | Mail Merge | 1 | 11-13-2014 05:36 PM |
![]() |
JUST ME | Word VBA | 4 | 03-25-2014 06:56 AM |
![]() |
MJP143 | Excel | 1 | 02-11-2013 05:07 AM |
![]() |
tinfanide | Excel Programming | 2 | 06-10-2012 10:17 AM |