Friday, June 18, 2021
  • Index
  •  » Automator
  •  » Copy Cell in excel and add text to copyed content.

#1 2020-05-19 06:02:22 am

MacPhisto
Member
Registered: 2007-05-08
Posts: 2

Copy Cell in excel and add text to copyed content.

Hi
Im trying to simplify a task in excel, and i need to copy text from cell A "purple" and paste this inn cell N m:\path\to\picture\server\purple.jpg

cell A2 contains: "purple"
cell N2 is empthy and ends up with: m:\path\to\picture\server\purple.jpg
cell A3 contains: "blue"
cell N3 is empthy and ends up with: m:\path\to\picture\server\blue.jpg
cell A4 contains: "black"
cell N4 is empthy and ends up with: m:\path\to\picture\server\black.jpg¨

I have the copy from cell to cell giong, but how do i insert my clippboard betwene "server/ and .jpg

Help please?❤️

Offline

 

#2 2021-06-16 06:57:15 am

Mockman
Member
From:: Toronto
Registered: 2020-05-27
Posts: 45

Re: Copy Cell in excel and add text to copyed content.

Belatedly, to my mind, this is better suited to applescript than automator but assuming that your workflow already has the workbook open and the worksheet active, then you could probably add a 'run applescript' action which contains the following applescript code.

Applescript:

on run {input, parameters}
   
   tell application "Microsoft Excel"
       tell active sheet of active workbook
           
           set lString to "m:\\path\\to\\picture\\server\\"
           set rString to ".jpg"
           
           set aRg to range "A2:A4"
           set nRg to range "N2:N4"
           repeat with x from 1 to count of cells of aRg
               set value of cell x of nRg to lString & value of cell x of aRg & rString
           end repeat
           
       end tell
   end tell
   
   return input
end run

There isn't likely a need to use the clipboard for this type of task. Just determine the strings —note that each backslash in the path requires its own backslash— and then loop through the ranges to assemble the final strings and place them into the appropriate cell.

What happens with each cell is this:
   

set value of cell 1 of range "N2:N4" of active sheet of active workbook to "m:\\path\\to\\picture\\server\\purple.jpg"

Filed under: applescript, excel, Automator

Offline

 
  • Index
  •  » Automator
  •  » Copy Cell in excel and add text to copyed content.

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)