Replace tags with images

Hi
<br />I'm tryng to build a vb script that replace text tag with images.
<br />Tags are like <%img=c:\logo.jpg%>. I need to replace the tag with the image c:\logo.jpg.
<br />I try this (It didn't work). Can somebody help me?
<br />thanks
<br />
<br />On Error Resume Next
<br />
<br />Set myInDesign = CreateObject("InDesign.Application.CS3")
<br />Set myDocument = myInDesign.ActiveDocument
<br />
<br />Set myTextFrames = myDocument.TextFrames
<br />'Get the total number of textframes
<br />myTextFrameTotal = myTextFrames.Count
<br />
<br />REM : replace tag <%img=c:\logo.jpg%> image with image c:\logo.jpg
<br />'Setup a loop through all textframes
<br />For myloop = 1 To myTextFrameTotal
<br />
<br /> Set myTextFrame = myTextFrames.Item(myloop)
<br />
<br /> myCharacterCount = myTextFrame.Characters.Count
<br /> If myCharacterCount &gt; 0 Then
<br />
<br /> id1= InStr(1, myTextFrame.Texts.Item(1).Contents, "<%img="  ,1)<br />        If  id1 >0  Then        <br />             id2= InStr(1,  myTextFrame.Texts.Item(1).Contents, "%>" ,1)
<br /> If id1 &gt;0 Then
<br />
<br /> REM: image filename
<br /> myFile = trim(Mid(myTextFrame.Texts.Item(1).Contents, id1+6, id2-id1-6) )
<br /> REM: set tag to ""
<br /> myTextFrame.Texts.ItemByRange(id1, id2).Item(1).Contents = ""
<br />
<br /> REM myTextFrame.Fit idFitOptions.idProportionally
<br /> REM myTextFrame.Fit idFitOptions.idContentToFrame
<br /> REM: insert image file
<br /> myTextFrame.InsertionPoints.Item(1).Place (myFile)
<br />
<br /> end if
<br /> end if
<br /> end if
<br />
<br />Next 'Process the next text frame in text frames
<br />
<br />if Err.Number&gt;0 then MsgBox Err.Description + ", " &amp; Err.Source
<br />
<br />REM myPub.SaveAs ("")
<br />REM myPub.Close
<br />REM myInDesign.Quit
<br />REM Set myDocument = Nothing
<br />REM Set myInDesign = Nothing

Hi Robert
<br />Thanks for your help.
<br />
<br />I get this message error:
<br />"Topic not optional. Vbscript error run time."
<br />
<br />The problem seems to be with instruction:
<br /> myTextFrame.Texts.ItemByRange(id1, id2).Item(1).Contents = ""
<br />and
<br /> myTextFrame.InsertionPoints.Item(1).Place (myFile)
<br />
<br />Image is inserted but NON in the tag position and tag postion is not emptied.
<br />
<br />I do not understand if "id1, id2" for ItemByRange function are simple integer or must be a kinf of object.
<br />
<br />On Error Resume Next
<br />
<br />Set myInDesign = CreateObject("InDesign.Application.CS3")
<br />Set myDocument = myInDesign.ActiveDocument
<br />
<br />Set myTextFrames = myDocument.TextFrames
<br />'Get the total number of textframes
<br />myTextFrameTotal = myTextFrames.Count
<br />
<br />msgbox myTextFrameTotal
<br />
<br />REM : replace tag <%img=c:\logo.jpg%> image with image c:\logo.jpg
<br />'Setup a loop through all textframes
<br />For myloop = 1 To myTextFrameTotal
<br />
<br /> Set myTextFrame = myTextFrames.Item(myloop)
<br />
<br /> myCharacterCount = myTextFrame.Characters.Count
<br /> If myCharacterCount &gt; 0 Then
<br />
<br /> id1= InStr(1, myTextFrame.Texts.Item(1).Contents, "<%img="  ,1)<br />    If  id1 >0  Then        <br />       id2= InStr(1,  myTextFrame.Texts.Item(1).Contents, "%>" ,1)
<br /> If id2 &gt;0 Then
<br />
<br /> REM: image filename
<br /> myFile = trim(Mid(myTextFrame.Texts.Item(1).Contents, id1+6, id2-id1-6) )
<br />
<br /> msgbox myFile
<br />
<br /> REM: set tag to ""
<br /> myTextFrame.Texts.ItemByRange(id1, id2).Item(1).Contents = ""
<br />
<br /> REM myTextFrame.Fit idFitOptions.idProportionally
<br /> REM myTextFrame.Fit idFitOptions.idContentToFrame
<br /> myTextFrame.InsertionPoints.Item(1).Place (myFile)
<br />
<br /> end if
<br /> end if
<br /> end if
<br />
<br /> if Err.Number&gt;0 then MsgBox Err.Description + ", " &amp; Err.Source
<br />
<br />Next 'Process the next text frame in text frames
<br />
<br />REM myPub.SaveAs ("")
<br />REM myPub.Close
<br />REM myInDesign.Quit
<br />REM Set myDocument = Nothing
<br />REM Set myInDesign = Nothing

Similar Messages

  • Replace words with images, in a table, using the search/replace tool

    Hello everybody
    I have a question:
    Is it possible to replace words with images, in a table, using the search/replace tool?
    My case:
    I have a table with about 9000 articles on about 400 pages. In this table there are words which I like to replace with Logos.
    Example: The word "DM" should be the Logo "DM" (.eps). This word is about 1200 times in this table.
    Is it possible to replace it automatically?
    Thank you very much for your helb.
    Kind regards Alex

    Hello Mr. Werner
    Thank you for your reply.
    Can I ask you which Version of InDesign do you use?
    I use CS 5.5 and there I can't find the change field "other" you told me.
    Can you see it on the screenshot? (Sorry it is german...)
    Thank you very much for your support.
    Kind regards Alex

  • Use Powershell to replace text with image in Word document

    I have a powershell script that uses a Word document as a template to create signatures that I am pushing out to my organization.
    The document is populated with text formatted the way I want the signature to look, that I then do a FindText and ReplaceText on.  This works fine for replacing text with text, but I can't figure out how to properly replace some of the holder text with
    an image and a link.  I found a few posts about adding images to word documents, but none that seem to work properly in this scenario.
    Any insight would be greatly appreciated, thanks!

    Dear BOFH,
    You are correct that method I outlined is not for inserting an image into a signature block (which would be in Outlook, not Word).  The links you post do certainly deal with outlook signatures, well done... Except that the question was about how to
    use a Powershell script to replace text in a Word document with an image.  Sure it was framed in the context of creating signatures, but the poster expressed that they already had a method of generating and replacing text, and just needed to know, as
    I did, how to do the thing they actually asked.
    Please BOFH... Please forgive my audacity in hoping to find a reference (any reference) to how to replace Word text with images via Powershell in a thread titled "Use Powershell to replace text with image in Word document".
    This is certainly a scripting question, and even something as simple as "You will need to call the .NET methods for the Word find/replace functionality.  Please ask in the Word forums for the correct method to use. 
    If you need help on calling .NET methods look HTTP ://here"support you offered combined with the contempt you offer in response to my actual substantive help to the actual question asked.
    BOFH, you are not better than us, just more arrogant.
    Can you please start your own question as this one has been closed.  Please see scripting guidelines.
    We cannot guarantee you satisfaction as this is a user supported forum.  The is no SLA for community support.  Perhaps if you posted a better worded question as a new topic someone might be able to help you resolve your issue.
    The topic you are posting on is closed and answered.
    ¯\_(ツ)_/¯

  • Replacing bullets with images

    Are there plans to add the option of replacing the bullets in a bulleted list with images, as you can do in Word? Our current workaround is to insert the image as a background image through the CSS with appropriate spacing, but this isn't very accurate.

    Hello Michael,
    Since the rendering of bullets is up to the browser, we don't have much control over that other than what the browser can provide. According to CSS, I believe the correct style to use would be "list-style-image," but it is not well-supported, and the ICE browser in OHJ does not currently support it.
    I am not sure what MS Word does, but when you save a Word file as HTML, it does all sorts of strange things to the HTML. For example, a quick test showed that saving a list (with custom bullets) as HTML created a series of P elements with things like <span style='font-family:Symbol'>^<span
    style='font:7.0pt "Times New Roman"'>       </span></span>
    You could do things like that, too, but it isn't good HTML.
    -Ben
    Oracle Help team

  • Replacing footage with image sequence

    Hi,
       I was wondering if anyone knew how to replace footage with an image sequence. It seems like when I choose replace footage and navigate to my image sequence there is nothing I am able to check off for image sequence. So basically if I have an image sequence in my timeline, I can only replace it with a movie which defeats the purpose of using an image sequence. Thanks in advance!

    You need to have a single directory filled with one or more supported still images which are named with a number a the end for the 'Image Sequence' checkbox to be un-grayed out in the 'Import', 'Replace Footage' or 'Locate Files' dialog. From the screenshot above, it looks like you've met all those criteria and that the checkbox is not even there, as opposed to being present but dim. On windows 8 (which it looks like you're on) that checkbox would be in between the 'File Name' label and the bottom of the file list area. The fact that you're not there makes me think your on an older version before we had all the relevant features. I'd have to check to remember just when that would have been, but I know that as of CS6 the 'Image Sequence' dialog was definitely there for the Locate Files and Import dialogs, so it's reasonable that it was an option in the replace footage dialog too. It may be something system specific which is not allowing all the UI to draw in correctly when using OS dialogs. In that case, Kevin's suggestion might still be viable since the Link & Locate workflow uses its own Premiere UI instead of OS dialogs.

  • Search .docx and replace text with image

    I've got a directory containing a series of images. The images will always be the same name and I need to insert them into placeholders in a Word document which will be a template. I thought of using the image names as placeholders, opening the document
    and searching for the image name, replacing it by inserting the image, and doing so for each image in the directory.
    $file is the name of the image in the directory and it loops through them okay.
    foreach($file in Get-ChildItem $savepath -Filter *.jpg)
            # search word doc and replace selected text with image ($file)    
    Also inserting the image seems simple enough from a TechNet article I found, but I've got no idea how to open the Word document and do a search and replace. I found a few articles related to the subject but I couldn't get them to work when I tried to adapt
    them.
    Any help is appreciated. Thanks in advance.

    This 'might' be possible, but I'm having a hard time finding good references to the com object capabilities for inserting an image into a word document.  Creating new, converting format, that sort of thing is straightforward.
    I'd do a search on "powershell word comobject" and variations of insert image update edit, etc.  Or maybe someone else with more experience/knowledge has a magic bullet for you.  Once you get some info on doing it with powershell, expand
    your search by omitting the powershell keyword, there's gotta be some solid documentation for the comobject somwhere, but it will probably be a bit complex.
    You can also:
    $word = new-object -comobject word.application
    $doc = $word.documents.add("<path to word document>"
    and get-member to your heart's content, but finding references and/or documentation might be easier.  
    Good luck!
    Edit:  This could help, but really doesn't give much insight into placement of the image, only helps getting the image into the doc:  http://gallery.technet.microsoft.com/office/44ffc6c8-131f-42f1-b24b-ff92230b2e0a
    If you do find something useful, post it here, I'm sure others could benefit!
    SubEdit:  Should have thought of this already...
    http://msdn.microsoft.com/en-us/library/ff837519(v=office.14).aspx

  • Replace text with images

    Hi,
    I'm using a script found here, to replace @equ001.pdf@ with the corresponding image, same for eq002 etc.
    This script works more or less ok for me.
    Sometimes, it removes some image names without replacing the image, sometimes it was leaving some "@" here and there.
    Sometimes, it's giving me an error on the "place image" code, saying it cannot find the image, giving it's path ending with the grep expression $2 and doesn't work at all.
    Sometimes it does part of the job, stops, gives the same error as above, and continues to work when I click ok.
    Today, it didn't worked on a document. I copied the text to work on into a new InDesign document an there, it worked (but in two times).
    Is there any other way of doing this ?
    if(app.documents.length != 0){
        var myFolder = Folder.selectDialog ('Choose a folder with images');
        if(myFolder != null){
            // reset the Find/Change dialog
            app.findGrepPreferences = app.changeGrepPreferences = null;
            // formulate a grep search string
            app.findGrepPreferences.findWhat = '@.+?@';
            // find all occurrence, last one first
            f = app.activeDocument.findGrep (true);
            for (i = 0; i < f.length; i++){
                // construct file name
                name = f[i].contents.replace (/@/g, '');
                // place the image
                var placedObjects = f[i].insertionPoints[0].place (File (myFolder.fsName + '/' + name));
        // delete all @??@ codes
        app.activeDocument.changeGrep();
    else{
       alert('Please open a document and try again.');

    You should process the found instances back to front:
    for (i = f.length-1; i >= 0; i--)
    Peter

  • Replace text with image using Applescript in InDesign CS5

    Hi to everyone, i'm looking for some suggestions to resolve my problem.
    I've to replace some strings with jpeg images stored on my pc
    Here is the code to replace two strings with the new ones.
    tell application "Adobe InDesign CS5"
              set myDocument to active document
              set myPage to page 1 of myDocument
              set stringsToReplace to {"111", "222"}
      repeat with iterator from 1 to (count stringsToReplace)
           set find text preferences to nothing
           set change text preferences to nothing
           set myFoundItems to nothing
           set element to item iterator of stringsToReplace
          if element is "111" then
               set find what of find text preferences to "111"
               set change to of change text preferences to "ONE"
               set myFoundItems to change text
               display dialog ("Found : " & (count myFoundItems) & " occurences of " & element)
          else if element is "222" then
               set find what of find text preferences to "222"
               set change to of change text preferences to "TWO"
               set myFoundItems to change text
               display dialog ("Found : " & (count myFoundItems) & " occurences of " & element)
          end if
              end repeat
      set find text preferences to nothing
      set change text preferences to nothing
    end tell
    Can you hel me?
    Thanks in advance.

    Hello, I have a couple of questions for you… How come you have strings in text frames… Would you not be better off using labels for this…? ( thats how I would do this ). Off the top of my head I think you will need to remove any text content from the frame to be able to change it's content type… only then will you be able to place a graphic… How are you associating your strings with the required image files… Do you have this in some extenal file Excel or FMP.

  • Replace Buttons with Images.

    Folks,
    I have buttons in my application which perform a certain functions
    by clicking on them.
    I want to replace the buttons by gif/jpg images,so that when the
    user clicks on them,it does the same set of functionality as discussed
    above.
    HOW CAN I REPLACE THE BUTTONS with Gif and implement the actionListener??

    Hello,
    there are several methods to set the icon for the button like setIcon and setRolloverIcon etc. You better setContentAreaFilled(false) if you want an icon-only button. Have a look at [url http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/AbstractButton.html]AbstractButton for further information.
    Regards,
    Tim

  • How to replace string with image( Say Smiley).........????

    Hello To All Experts !!
    I wanna looking for some help in displaying image in my text area when should i type ":)" in text field.....
    I got some program through forums....
    import java.util.*;
    import javax.swing.ImageIcon;
    public class TokenizeSmiley {
        private static final HashMap SMILEYS;
        static {
            SMILEYS = new HashMap();
            SMILEYS.put(":)", new ImageIcon("images/1.gif"));
            SMILEYS.put(";)", "<wink>");
        public static void main(String[] args) {
            String text = "Hello!! :) How are you ;)";
            StringTokenizer st = new StringTokenizer(text);
            String token;
            while (st.hasMoreTokens()) {
                token = st.nextToken();
                if (SMILEYS.containsKey(token))
                    token = (String)SMILEYS.get(token);
                System.out.print(token + " ");
    }but it is showing <smile> and <wink> as it is given...i tried to give path of image ...but it is nt fetching then also.....
    Plz help in this....
    Message was edited by:
    Damz@del

    So your data is stored in XML. So what? You haven't asked a question about the XML or how to format it or how to access it. You asked a question that had nothing to do with XML at all. It's as if you said "My data is stored on a Windows computer so I will call Microsoft's support line to ask them this question."
    And I can't even suggest a suitable forum because a "text area" could be an AWT component or an HTML component. But I do suggest you ask in the right place.

  • How to replace string with image( Say Emoticons )??

    Hello Friends !!
    I am working on chat messenger and want some help in "How to access Emoticons when somebody typed :), ;), :)) and many more strings.....?"
    Is there any sample code to do that job or any function to perform such task??
    Thanks in Advance....

    use event listener... found match, load image instead of text on the fly.

  • Replace default contacts images

    This may seem small compared to losing all contacts or something, but it makes me batty. I would like to add an image to a contact card in "Contacts."
    Yes, I know how to add a default image, but what good is placing a #@$%# basketball or a snowflake going to do??
    And how stupid is it that the camera option is ready to take a picture of me?? So every contact in my Address Book will have a picture of me? Who thought of that?
    I want:
    A) an image of my friend (duh). I may not have it in iPhoto. It may be something I screenshot off of FB. A picture.
    or
    B) a map -maybe instead of a face, I want a picture of a building where they work or a map pic to their home, this would actually be useful.
    I do not want, and cannot imagine a use for, a random image of a flower. Was somebody high when they created these options?
    So can somebody tell me how I can go to wherever those dumb images are stored, in whatever library or folder, make them visable, delete them and replace them with images I would actually use?
    TIA.

    Glad that helped!
    I find sometimes with Apple products, simply trying what seems intuitively like it should work actually does work.  I don't recall ever seeing this documented either, but it seemed like it was worth a try.
    Enjoy your Apple products.

  • Can we replace OTR text with Images?

    Hi All,
    I just wanted to know can we replace OTR text with Images?
    or
    Can we define an image as an OTR text? so that it can be placed in the page where OTR text is used.
    regards...
    Ravi

    Hi Ravi,
    it is possible to replace an OTR Text with an image.
    You first have to define the Link in the OTR Text where your image is located. This can be everywhere in the Internet or better on a secured intranet server which everyone can reach easily without permission problems. Maybe in the DMZ.
    You can even link it into the MIME Repository of your SAP System as well.
    Then you have to put that OTR Text into a
    <htmlb:textview> Tag and ensure that the switch
    " encode = "TRUE" is enabled.
    Well thats all.
    Keep in mind that the a different language, set in the Internet Explorer or other viewing instances, disables the link if it not "translated" into that language.
    This can also be an advantage if you got multilingual fixed pictures with drawn text in it.
    I suggest you put all your links ( with a Value Field and at least a name field) into a seperate table into the repository for easy maintaining.
    Greetings,
    Dominik
    Edited by: Dominik Lemke on Dec 19, 2007 12:02 PM

  • Tagging an image with a callout and caption

    The document is created in MSWord 2013. It contains screen captured images along with added call-outs and a caption for each (see image #2 below). The call-outs extend outside the image border. I used the 'group' option in Word to group each of the elements together as they tend to move around the page during the editing process. The 'picture' group is formatted as 'inline with text' or 'top and bottom'. 
    In Adobe Acrobat XI Pro, I am trying to fix the tags for the figures. Although each of the elements are group in Word, they are appearing as separate elements/tags. (see image #1 below) ...the image is one Figure, the call-out is another Figure and the caption is yet another Figure. How should I handle this type of situation?  I have tried:
    1. to tag all three elements as a 'Figure'. Sometimes this works; sometimes the caption and/or the text in the call-out disappear.
    2. to tag all three elements as a 'Figure/Caption'; however, I get the same results as above...sometimes the caption and/or text in the call-out disappear.
    3. I also tagged the call-out as 'background' and then tagged the image and caption together as either 'figure' or 'figure/caption'; however, when selecting the image and caption, I must select the call-out as well because of it's proximity to the image. End result: text in call-out disappears.
    What is the proper way to tag in this situation?
    As an aside, I find the entering the ALT text in MSWord does not carry over to the PDF. I've experimented with the too. I've added the ALT text to the image on its own and to the group. I've added it to the "Title" field; however, the ALT text field in the PDF is empty. I've given up on adding this in Word and now add them directly to the tag.
    If someone can help point me in the right direction on how to fix the tag issues for images/callouts/caption, I'd be very grateful!!!!!  (BTW, using a page layout application is not an option. I must use MSWord 2013 to create my documents.)

    HI 'C' student!
    Thanks for the info. I will give the Content pane a try.
    I think my Word 2013 might have a bug.  When i enter text into either the 'title' field or the 'description' field, the text does not move over or wrap around so that i can fully see what i've entered. i wonder if this is impacting the carry-over into the pdf file?
    the company I work for does not 'officially' support this version of Word, as i am an 'early adoptor' of this version. until the rest of the company moves to this version, i'm kinda on my own. i am going to see who i can speak with to see about getting an update, though. maybe that will fix the problem.
    thanks again,

  • Replace Internet Explorer Image with Site Image

    I would like to replace the IE image or any image in the
    address bar with the image of the website. Is this doable and if so
    how would I go about doing this.
    Thank you in advance.

    canadianflower wrote:
    > I would like to replace the IE image or any image in the
    address bar with the image of the website. Is this doable and if so
    how would I go about doing this.
    Google favicon.ico.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

Maybe you are looking for

  • Report of Groups owned along with group memberships for each group, all in a single .csv file

    Hello all, What I'm trying to do is generate a report of all groups owned by a specific user, along with the group memberships, and output it all to a single .csv file. In the .csv file, I would like to have the group names as the column headers, and

  • Smartform pdf or mail

    Hi All, In smartForm how to send mail and  how to convert it in to pdf file .can any one write the pseudocode? Thanks in Advance,

  • Can't create URL??

    Hi all... I'm trying out on this piece of code that reads the HTML file and then display it in a JEditorPane. Problem is, seems like I'm unable to create a new URL file?? Here's part of the code:      private JEditorPane createEditorPane(String htmlN

  • Problem with audio after encoding

    Hi, In my movie I added a couple of songs. When playing back the DVD I created with iDVD (using professional encoding), I realised the audio of the songs was very distorted or something. It didn't sound very clear or crisp. I had originally saved the

  • Dynamic Combo Boxes

    Hi, I have an interface that has 2 combo boxes; in the first you select a product, in the second a type of that product. Now how is possible to make a dynamic changing content combobox? Thanks