DomC Posted October 17, 2015 Share Posted October 17, 2015 (edited) Hi Maybe not the right forum for worksheet formula questions. I am searching a way to insert an image in a worksheet cell by using a formula. I already searched the forum but could not find any related questions. What I am trying to do: If want to show an image in cell D1, if the cell A1 has the value greater than "0". =if((A1<>0), 'here i want an Image', 'false') I tried this: =IF((A1<>0), (IMAGE(N='k1')), '') #-> cell is empty =IF((A1<>0), D1, '') #D1 is refering to the cell "D1" which shows the image by =IMAGE(N='k1') =IF((A1<>0), IMAGE(N='k1'), '') #-> cell is empty also tried from other direction: =IMAGE((IF((A1<>0), "N='k1'", ''))) #-> error because of the double quote I think =IMAGE(E1) #Simple test, if IMAGE() formula can use values from other cells I give up... Any tips? Edited October 18, 2015 by DomC Quote Link to comment
DomC Posted October 17, 2015 Author Share Posted October 17, 2015 One step nearer to the solution ... anything goes with script, forget crampy worksheet formulas. #Formula in Worksheet: =RUNSCRIPT('script-1') #python script-1: A1=vs.CellValue(1,'A') pic=vs.GetObject('pic-1') if A1 >= 0: pic=vs.GetObject('pic-2') vs.WSScript_SetResImage(pic) "Just" have to find cell number, the script runs. To read out relative cells to the script cell. Quote Link to comment
twk Posted October 18, 2015 Share Posted October 18, 2015 Interesting approach Dom, haven't tried to scripts via worksheets but they look they could solve alot of headaches.. Quote Link to comment
Rollin Posted December 26, 2015 Share Posted December 26, 2015 Does anyone have a sample worksheet using RunScript in a cell? I cannot get any scripts to run. using Vectorworks Architect 2016 on OS X thanks for any help. Quote Link to comment
Rollin Posted December 26, 2015 Share Posted December 26, 2015 Does anyone have a sample worksheet using RunScript in a cell? I cannot get any scripts to run. using Vectorworks Architect 2016 on OS X thanks for any help. Quote Link to comment
Rollin Posted December 26, 2015 Share Posted December 26, 2015 Does anyone have a sample worksheet using RunScript in a cell? I cannot get any scripts to run. using Vectorworks Architect 2016 on OS X thanks for any help. Quote Link to comment
Rollin Posted December 26, 2015 Share Posted December 26, 2015 Does anyone have a sample worksheet using RunScript in a cell? I cannot get any scripts to run. using Vectorworks Architect 2016 on OS X thanks for any help. Quote Link to comment
DomC Posted December 26, 2015 Author Share Posted December 26, 2015 Hi Attached, an Example. Dom 1. Script in the cell: =RUNSCRIPT('kantenbild-script') 2. Script which will be executed: sheet_h=vs.ActSSheet() if sheet_h != None and vs.GetName(sheet_h)!='XGST-VSSM Liste mit KB': numRows, numColumns=vs.GetWSRowColumnCount(sheet_h) startrow=9 rows=numRows-startrow for x in range(rows): kabi=[] k=[] k1=vs.GetWSCellString(sheet_h,x+startrow, 14) k2=vs.GetWSCellString(sheet_h,x+startrow, 16) k3=vs.GetWSCellString(sheet_h,x+startrow, 18) k4=vs.GetWSCellString(sheet_h,x+startrow, 20) k=([k1],[k2],[k3],[k4]) for i in range(4): if k[i] !=['']: kabi.append('1') if k[i] ==['']: kabi.append('0') vs.SetWSCellVertAlignment(sheet_h, startrow, 24, numRows, 24, 3) vs.SetWSColumnWidth(sheet_h, 24, 24, 37) vs.SetWSImgSizeType(sheet_h, x+startrow, 24, x+startrow,24, 1) vs.SetWSImgSize(sheet_h, x+startrow, 24, x+startrow, 24, 48, 48) vs.SetWSRowHeight(sheet_h, startrow, numRows, 37, True, True) vs.SetWSCellFormula(sheet_h, x+startrow, 24, x+startrow, 24, '=IMAGE(N=\'n.vssm.k'+str(kabi[0])+str(kabi[1])+str(kabi[2])+str(kabi[3])+'\')') Quote Link to comment
Rollin Posted December 27, 2015 Share Posted December 27, 2015 Thank you! That is what I needed. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.