Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Excel AddCode in worksheet
#1
I tried:

Macro Macro43
Code:
Copy      Help
ExcelSheet es.Init
str strCode =
;Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
;'Update 20140318
;Static xRow
;Static xColumn
;If xColumn <> "" Then
;;;;;With Columns(xColumn).Interior
;;;;;;;;;.ColorIndex = xlNone
;;;;;End With
;;;;;With Rows(xRow).Interior
;;;;;;;;;.ColorIndex = xlNone
;;;;;End With
;End If
;pRow = Selection.Row
;pColumn = Selection.Column
;xRow = pRow
;xColumn = pColumn
;With Columns(pColumn).Interior
;;;;;.ColorIndex = 20
;;;;;.Pattern = xlSolid
;End With
;With Rows(pRow).Interior
;;;;;.ColorIndex = 20
;;;;;.Pattern = xlSolid
;End With
;End Sub

es.AddCode(strCode)

but it doesn't work.

Is possible to insert the code in Worksheet or ThisWorkbook module?
#2
Another way...

Can you help me to convert:

s.FormatConditions.Item(1).Borders.Item(Excel.xlDiagonalDown).LineStyle = Excel.xlNone

Error (RT) in <open ":1320: /252">highligh_cell_cross_excel:  0x80020009, Ocurrió una excepción.

0x3EC, No se puede asignar la propiedad LineStyle de la clase Border.    <help #IDP_ERR>?

Function highligh_cell_cross_excel
Trigger CSAi     Help - how to add the trigger to the macro
Code:
Copy      Help
ExcelSheet a.Init
Excel.Range s=a.ws.Range("1:100")

s.FormatConditions.Delete
s.FormatConditions.Add(Excel.xlExpression 0 "=Y(CELDA(''col'')=CELDA(''col'';A1);CELDA(''row'')>CELDA(''row'';A1))")
s.FormatConditions.Item(1).Borders.Item(Excel.xlDiagonalDown).LineStyle = Excel.xlNone
;s.FormatConditions.Item(1).Borders(Excel.xlDiagonalUp).LineStyle = Excel.xlNone
s.FormatConditions.Add(Excel.xlExpression 0 "=Y(CELDA(''row'')=CELDA(''row'';A1);CELDA(''col'')>CELDA(''col'';A1))")
s.Calculate



;;;;Selection.Borders(xlDiagonalDown).LineStyle = xlNone
;;;;;Selection.Borders(xlDiagonalUp).LineStyle = xlNone
;;;;;With Selection.Borders(xlEdgeLeft)
;;;;;;;;;.LineStyle = xlContinuous
;;;;;;;;;.Color = -11489280
;;;;;;;;;.TintAndShade = 0
;;;;;;;;;.Weight = xlThin
;;;;;End With
;;;;;Selection.Borders(xlEdgeTop).LineStyle = xlNone
;;;;;Selection.Borders(xlEdgeBottom).LineStyle = xlNone
;;;;;With Selection.Borders(xlEdgeRight)
;;;;;;;;;.LineStyle = xlContinuous
;;;;;;;;;.Color = -11489280
;;;;;;;;;.TintAndShade = 0
;;;;;;;;;.Weight = xlThin
;;;;;End With
;;;;;Selection.Borders(xlInsideVertical).LineStyle = xlNone
;;;;;Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
;End Sub
#3
Macro Macro3037
Code:
Copy      Help
ExcelSheet a.Init
Excel.Range s=a.ws.Range("C1")

typelib Excel

s.Borders.Item(xlDiagonalDown).LineStyle = xlNone
Border b=s.Borders.Item(xlEdgeLeft)
b.LineStyle = xlContinuous
b.Color = 0x0000ff
;b.TintAndShade = 0
b.Weight = xlThin

FormatConditions - here exception too.
AddCode - here exception too, something about security.
#4
Any idea on improving the visibility of the active cell in Excel?


Forum Jump:


Users browsing this thread: 1 Guest(s)