Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Excel COM cell custom font size color


Best Answer Jackie Sztuk _Blackholyman , 23 October 2014 - 12:43 PM

Go to the full post »


  • Please log in to reply
1 reply to this topic
hot hot 85
  • Members
  • 72 posts
  • Last active: Sep 29 2015 05:40 AM
  • Joined: 27 Jun 2011

Hi  AHK World

 

I try to chance the font ,color,size,color background.wth COM.

 

This is the code From VB (Excel macro recorder)

 

 Range("A1:O1").Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 49407
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    With Selection.Font
        .ThemeColor = xlThemeColorLight2
        .TintAndShade = 0.399975585192419
    End With
    With Selection.Font
        .Name = "Calibri"
        .Size = 16
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ThemeColor = xlThemeColorLight2
        .TintAndShade = 0.399975585192419
        .ThemeFont = xlThemeFontMinor
    End With
    With Selection.Font
        .Name = "Arial"
        .Size = 16
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ThemeColor = xlThemeColorLight2
        .TintAndShade = 0.399975585192419
        .ThemeFont = xlThemeFontNone
    End With
    Cells.Select
    Cells.EntireColumn.AutoFit
End Sub

this is the code from AHK

 

oExcel := ComObjCreate("Excel.Application")
oExcel.WorkBooks.Add
oExcel.Visible := true


sleep 3000
oExcel.Range("a1").Value := "Fecha"
oExcel.Range("b1").Value := "hora"
oExcel.Range("c1").Value := "serial"
oExcel.Range("d1").Value := "tipo"
oExcel.Range("e1").Value := "naed"
oExcel.Range("F1").Value := "FALLA"
oExcel.Range("g1").Value := "defecto"
oExcel.Range("h1").Value := "linea"
oExcel.Range("i1").Value := "FALLA1"
oExcel.Range("j1").Value := "texto"
oExcel.Range("k1").Value := "componente"
oExcel.Range("l1").Value := "comentario"
oExcel.Range("m1").Value := "turno"
oExcel.Range("n1").Value := "numero"
oExcel.Range("o1").Value := "tipo 2"


sleep 3000
oExcel.Range("A1:O1").Select
oExcel.Selection.Interior
oExcel.Pattern = xlSolid
oExcel.PatternColorIndex = xlAutomatic
oExcel.Color = 15773696
oExcel.TintAndShade = 0
oExcel.PatternTintAndShade = 0


 
 
 

but appear this error

 

 

C:\Users\dario\Desktop\New folder (2)\New AutoHotkey Script (2).ahk (25) : ==> This line does not contain a recognized action.
     Specifically: oExcel.Pattern = xlSolid

 

 

someone know how can I fixed?

 

thanks in advance


Every day exist something new to learn

Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
✓  Best Answer
more then one this need to be fixed

here is and example i hope will help you
 
oExcel := ComObjCreate("Excel.Application")
oExcel.WorkBooks.Add
oExcel.Visible := true


sleep 3000
oExcel.Range("a1").Value := "Fecha"
oExcel.Range("b1").Value := "hora"
oExcel.Range("c1").Value := "serial"
oExcel.Range("d1").Value := "tipo"
oExcel.Range("e1").Value := "naed"
oExcel.Range("F1").Value := "FALLA"
oExcel.Range("g1").Value := "defecto"
oExcel.Range("h1").Value := "linea"
oExcel.Range("i1").Value := "FALLA1"
oExcel.Range("j1").Value := "texto"
oExcel.Range("k1").Value := "componente"
oExcel.Range("l1").Value := "comentario"
oExcel.Range("m1").Value := "turno"
oExcel.Range("n1").Value := "numero"
oExcel.Range("o1").Value := "tipo 2"


sleep 3000
oExcel.Range("A1:O1").Select

;~ With Selection.Interior
this := oExcel.Selection.Interior
{
	this.Pattern := xlSolid := 1
	this.PatternColorIndex := xlAutomatic := -4105
	this.Color := 15773696
	this.TintAndShade := 0
	this.PatternTintAndShade := 0
}
;~ End With
return
you need to set excels constants as autohotkey does not know them and also you need to tell the script what object or range to apply the changes to.

Hope it helps
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About