Applescript to replace a picture in a Word document

I am trying to create an Applescript to control Microsoft Word to replace a selected image in a document with a new image from a file.  The extracted problematic code is below.
  -- prior code sets up variables and seems to be working fine.
                    set {start of content:t_start, end of content:t_end} to text object of selection
                    set float to shapes of active document whose end of content of its anchor ≥ t_start and end of content of its anchor ≤ t_end
                    if float is not {} then --replacing a floating image as opposed to an inline image
                                   repeat with pic in float
            set a to anchor of pic
            set t to top of pic
            set l to left position of pic
        end repeat  -- repeat is not logically necessary but Word seems happier
         tell active document
            set np to make new picture at a with properties {file name:tfile2, save with document:true}
            set relative vertical position of np to rvp
                                                 set top of np to t
            set left position of np to l
         end tell
         delete pic
                    else
     -- rest of code handles when no selection exists or the selected image is inline and is working fine.
Everything is working fine - the existing picture is deleted and the new one is inserted and moved to the correct position but always on the FIRST page.  The anchor put into a contains the location of the old picture's anchor (which might have a start of content set to 2000 say) but when the new picture is created at a, the new picture is always created with an anchor with a start of content of 0 - regardless of the value in the original anchor.
What I need is either to create the new picture with an anchor that is on the old page OR move the anchor to the old page after creation - neither of which I have managed to achieve so far.
Any help or suggestions greatly appreciated.

The solution to this problem is to make the new picture using this command
set np to make new picture at a with properties {file name:tfile2, save with document:true, anchor:a}
Silly me.  I though that making the picture at "a" would set the anchor to "a". 

Similar Messages

  • 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.
    ¯\_(ツ)_/¯

  • How do I stop the spinning wheel that replaced the cursor in a Word document?

    How do I stop the spinning wheel that replaced the cursor in a Word document?

    Something is causing Word to lock up.  Restart the laptop and/or reinstall Office/Word to fix the instability.  Maybe even a bad plugin or document could be causing this if it's only happening when you open a particular doc.

  • Convert picture imported to Word document with VBA

    I've Word documents that contain acronyms and a macro that searches the document for them so that they can be identified for an acronym table. So far, I can search a document's text and tables but not the pictures with the macro. I've found that if
    I manually select the picture, right click and select group->ungroup, I get a MsgBox with the message "This is an imported picture, not a group. Do you want to convert it to a Microsoft Office drawing object?" Selecting the yes button converts
    it into many Shapes objects that are then searchable.
    I've determined that the picture (object) type prior to conversion is msoPicture and that it gets converted to an msoCanvas object with many Shape objects on it.
    I've built a macro that can loop through various Canvas objects and then the Shape objects to find the acronyms. Unfortunately, I haven't been able to find a way to convert the image/object from msoPicture to msoCanvas in VBA. Does anyone know how to do
    this? Thanks.

    Hi,
    As far as I know, we can’t convert a picture to canvas through VBA.
    For that process through the UI, I think it add the canvas first, then add the picture to that canvas.
    For your requirement, you could add the canvas first, then add the picture to tat canvas.
    Sub NewCanvasPicture()
    Dim shpCanvas As Shape
    'Add a drawing canvas to the active document
    Set shpCanvas = ActiveDocument.Shapes _
    .AddCanvas(Left:=100, Top:=75, _
    Width:=200, Height:=300)
    'Add a graphic to the drawing canvas
    shpCanvas.CanvasItems.AddPicture _
    FileName:="C:\Program Files\Microsoft Office\" & _
    "Office\Bitmaps\Styles\stone.bmp", _
    LinkToFile:=False, SaveWithDocument:=True
    End Sub
    Regards
    Starain
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Parsing and replacing text items in a word document?

    Hi,
    I was wondering if someone could point me in a
    good direction as to how I would store word documents
    in the database as BLOBs but then be able to open
    them in plsql and replace tags with values and
    save it as a new document???
    Thanks in advance!

    There are examples in the interMedia User's Guide on loading documents into OrdDoc type objects. Once you do that, you should have a relational interface to the object. Depending on the specific features that the Word plug-in supports, you may be able to edit the document in place via PL/SQL.
    I'm more familiar with the OrdImage object, which provides most of the basic image manipulation routines for most image formats. I assume that the OrdDoc object provides a basic document manipulation API as well.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Convert picture from word document to .jpg

    I'd like to know how to copy a picture from a word document and convert it to a .jpg format so I can use iphoto or other image software to edit and print it.  I tried a work-around that's not very satisfactory, that is to print the picture on photo paper, then scan it and save it as a .jpg, but as you would expect, I lose quality.

    Why don't you just use a Word converter to render and convert  Word document and the images cotained in Word file into jpeg image directly? Saving the Word file cotaining pictures as pdf and save as jpeg is more complicate converting the word file into jpeg image directly.

  • Importing a word-document to RH11 for output as WebHelp (Image-Quality)

    Hello guys,
    i have a problem with importing word-documents to RH11. It is not a problem with the process itself, but with the settings. After importing the documents to RH11 the image quality is absolutly messed up. The resolution is not even half of the original and its blurry. It seems to be that RH11 only takes a "screenshot" of the picture within the word document instead of importing the original high quality image.
    I am generating a manual and therefor im going to export the project as WebHelp Pro. My inconvinient solution is to export the high quality images from the word document manually and replace the messy pictures in the WebHelpPro folders. As you can imagin this is going to take a lot of time and resources while the project is getting bigger.
    Hopefully you can help me.
    Best regards from Germany and please pardon my English :-)

    So you are putting the image into Rh at 100% and then shrinking it there, correct?
    How are you shrinking it?
    If you are going to Image Properties and resizing there, you will get poorer results.
    Go to View > Pods > Tools > ReSize and you will get better results.
    Or use SnagIt.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • Can no longer see my I-photo photos, when trying to insert photo into Word Document.

    I had some computer problems and did upgrade to Snow Leopard from Leopard. Using older MacBook Pro. 
    Now, when I try to insert a picture into a Word Document, I cannot see my photos!
    I am working in a word document, I choose "Insert Photo from my files" and when the window comes up so I can choose the photo to insert... when I select the "photos" choice under the Media section on the Left side of the box that comes up, the box to the right is BLANK, both on the top and bottom!  None of my photos come up for selection. 
    This method to choose photos to insert into documents used to work before... now it is not.  After selecting "photos" all my photos would appear in the right box, and I would move through my I-photo events to choose my saved photo and insert it.  Yes, photos are showing and present in I-photo.  They just won't appear for importing.
    This is so frustrating, not to mention time comsuming trying to figure out what is going on and how to fix it.
    Can anyone help? Please?

    Oroilore-
    I do not see a way to disable the Picture Frame icon.  I looked at Settings-Picture Frame, but none of the options turns it off.  The only way I can thinik of, would be if all of your photos had been deleted.  If there were no photos, you couldn't have a slide show!
    One thing to try is to reset (reboot) your iPad.  Hold both the Home and Sleep buttons for several seconds until the Apple logo appears.  Ignore the "Slide to power off" arrow.  The iPad will restart after a couple of minutes.  Resetting this way will not hurt anything, and sometimes clears up mysterious problems.
    Fred

  • Inserting photo into word document with new Yosemite OS X

    iPhoto has gone away after downloading the new Yosemite OS X program.  Now it is Photos.  I am attempting to drag or insert a picture into a word document for work.  Unlike the old iPhoto, double clicking on the photo does not allow me to "Copy" so I may then "Paste" on my document.  In addition, when I attempt to drag the picture onto the document where I want it, the picture goes right back to the photo library.  Tried pretty much everything I know and my tech guys from work.  Anyone have this problem or know of the solution?

    My photos are not in/on iCloud. In Microsoft Word 2011 I can use
         Insert > Photo > Picture from File ...
    and then navigate to the my 'Pictures' folder and insert a picture successfully.
    Can't find a direct way of going from Photos to Word. In practice, this is not a big issue for me because in most cases I want to reduce the size of the image, which I do by selecting the image(s) I want in Photos.app, then switch to Preview.app, command-N (New from clipboard). Once in Preview.app I can transfer images to Word by drag and drop from the thumbnails, etc. The neat thing about this workflow is one can select several images in Photos at once and have them all open in Preview with one keystroke.
    C.

  • Word document to PDF File possible?

    Hi to all, im using mac mini at home, in office i use windows. in windows theres a software that converts word documents (or excel files or ppt files) to pdf file. is there a freeware on this for mac?
    my dilema is actually this: i am putting pictures in a word document and convert them to pdf.
    any help would be nice.
    Thanks

    Hi iSphere: Have you tried, going to "File" > "Print" then at the bottom of the print dialog box select "PDF" and then "save as PDF". This will create a PDF file to be saved.
    Hope this helps
    Stedman

  • HELP! I am having trouble when I try to paste a snap shot into a Word document!

    When I paste the picture into the Word document, the image is blurry.  What can I do to keep this from happening?

    Exactly what does this have to Adobe Reader? Please give details of Reader,  Word and your OS.

  • HP Envy 5530 enlarges photo inserted in a Word Document

    Whenever I insert a photo or picture into a Word Document it looks great on screen and on Print Preview, but when I print the page the picture has been enlarged so most of it is cut off.  It doesnt matter the placement of the picture.

    Hello there! Welcome to the forums , I read about the issues you are having when printing from Microsoft Word. I would like to offer you my suggestions. If you are running a Windows OS, run the Print and Scan Doctor tool to fix printing issues. If the issue is persistent and only occurs when printing from MS Word, please visit the Microsoft Forums for better exposure on the issue.How to troubleshoot print failures in WordMicrosoft Office Support I hope that helps you out, have a fantastic Monday

  • How can I change a Microsoft Word document file into a picture file?

    How can I change a Microsoft Word document file into a picture or jpeg file? I am wanting to make the image I created my background on my macbook pro.

    After I had the document image the way I wanted it, I saved it as a web page and went from there. Below are the steps starting after I did the "save as" option in Word:
    1) Select "Save As Web Page". I changed the location from documents to pictures when the window came up to save it as a web page.
    2) Go to "Finder" on you main screen, or if it's on your main toolbar at the bottom.
    3) Click on the "Pictures" tab and find the file you just re-saved as a web page. (I included "web page" or something similar in the new title so I could easily find the correct file I was looking for)
    4) Open the correct file and then "right click" on the actual image. (Use 2 fingers to do so on a Mac)
    5) Select 'Use Image As Desktop Picture", and voilà! The personally created image, or whatever it is that you wanted, is now your background.
    **One problem I encountered while doing this is that the image would show up like it was right-aligned in relation to the whole screen. The only way I could figure how to fix this was to go back to the very original document in Word, (the one before it was saved as a web page), and move everything over to the left.
    I hope this helps someone else who was as frustrated as I was with something that I thought would have been very simple to do! If you have any tips or suggestions of your own, please feel free to share. : )

  • When trying to look at pix on a cd, it comes up as word document and have to right click on preview to see picture. Why

    On my desktop, when wanting to see pictures on a CD, if I click on the picture icon it open as a word document. I must right click on the icon then click on preview and can then see all pictures on the CD. This just started after the last Firebos update. What needs to be done to correct. I have no problem seeing the pictures on my laptop which doen not have Firefox.

    Firefox is a web browser, and your problem is associated with how Windows handles image files. Firefox doesn't even need to be running, so I don't see how it could be associated with your problem. If the problem started around the same time as a Firefox update, I'm willing to bet that it was just a coincidence.
    Try asking in a Windows forum. http://windows.microsoft.com/en-US/windows/help/community

  • Word document with picture JPEG

    When I save a word document with a JPEG picture inserted to PDF the picture appears gray?

    Hi Martin,
    Are you viewing that PDF in Adobe Reader or Acrobat (and what version)?
    It sounds like you may have an option selected in the preferences that causes large images to appear as gray boxes. Please try this:
    Choose Edit > Preferences (Windows) or Acrobat/Reader > Preferences (Mac OS).
    Click the Page Display category on the left.
    Select Show Large Images, and then click OK.
    Did that do the trick?
    Best,
    Sara

Maybe you are looking for

  • I can not get itunes to open on Windows 7...

    I just got a new iPhone and wanted to back up my old iPhone to my computer one more time before switching over...Two hours later I still can not get iTunes to open.  I have two different acounts on my computer, iTunes will load on the secondary accou

  • Are there any APIs to create an Invoice in Oracle Payables?

    Hi, We have a requirement to import the invoices from the operational systems. We will be making approximately 7,000 checks a day. We need to import all these payments information into Oracle Payables as Invoices and then process the payments out of

  • Problems 1 and 2 with iPod Nano 7G described below

    Problem No. 1: I have followed the recommended steps for activating the sensor (Nike + Fitness) in my 7th generation iPod Nano to no avail.  Is there really a built-in sensor in this iPod Nano as part of the Nike + Fitness? Problem No.2: Songs remain

  • How to Download a Hierarchie to a Flat File

    Hallo Experts, sorry i just have a second question. We make the solution "How to Download a Hierarchy to a flat file" Program works transport green Upload ok, but the Text Node keys are there, but not the text e.g. description text note short: 000000

  • Automatic Gathering Statistics Script

    Hi, We must to schedule in our database some kind of job in order to monitoring the database and regularly gathering statitics of database objects (nowadays most of tables have been never analyzed). We have read the Oracle documentation in order to u