hi
I am trying to crop all the images in a MS Word doc.
I have written this but it is not working so far.
tell application "Microsoft Word"
   set myPics to inline pictures of active document
   repeat with pic from myPics
       set crop bottom of picture format of pic to 18
   end repeat
   close document 1 saving yes
end tell
I get an error stating
“An end of line can’t go after this identifier” for the line
repeat with pic from myPics
But I do not understand what this error means. if anyone can help explain the error and correct this code that would be great. It’s for MS Word 2011.
Thanks
         
        
          
        
           
           
           
         
         
            
            
          
       
      
        
        
          Hi there,
try this:
tell application "Microsoft Word"
	set myPics to inline pictures of active document
	
	repeat with pic in myPics
		set crop bottom of picture format of pic to 100
	end repeat
	
	close document 1 saving yes
	
end tell
Changed from to in here:  repeat with pic from myPics
         
        
        
           
           
           
         
         
            
            
          
       
      
        
        
          Thanks that works. I forgot to mention that I am using this through Automator and I had also made the mistake of not passing the arguments through Automator as well. I want it to crop every image in every Word Doc in a folder.
Here is the final working code.
on run {input, parameters}
	repeat with aFile in input
		tell application "Microsoft Word"
			try
				open aFile
				set myPics to inline pictures of active document
				repeat with pic in myPics
					set crop bottom of picture format of pic to 500
				end repeat
				close document 1 saving yes
			on error
				try
					close document 1 saving no
				end try
			end try
		end tell
	end repeat
	return input
end run
         
        
        
           
           
           
         
         
            
            
          
       
      
        
        
          Hhhhmmm?  
I’ve just tried my script above, having placed some more images on the page, and it still works?
I’m running the script straight from Script Debugger. I’ve also tried it in AS Editor and it worked ok.
Wonder if it’s something to do with you using Automator?
         
        
        
           
           
           
         
         
            
            
          
       
      
        
        
          Yes
Thanks for your help, I had just realised that and so amended my above post, to hopefully avoid you having to re-look at it.
It was an automator issue, you were correct.
Thanks again
         
        
        
           
           
           
         
         
            
            
          
       
      
        
        
          Glad to learn it’s sorted. 