Hi everyone,
Can you help me with this wrong Excel automation code ?
excel.Range(“E:M”).Select_
excel.Selection.ColumnWidth = 15
excel.Selection.WrapText = True
excel.Selection.HorizontalAlignment= Office.xlCenter
Debugger Issue : “excel.Selection.HorizontalAlignment= Office.xlCenter” - This item does not exist
Thanks for your help
Jrme
Why use the select command? Can’t you just set your range to a variable and use that?
rng = excel.Range(“E:M”)
rng.ColumnWidth = 15
rng.WrapText = True
rng.HorizontalAlignment= Office.xlCenter
Not sure if this has any effect on your issue (don’t know which part of the code is causing the error = the HorizontalAlignment, or the Office.xlCenter - which one is highlighted in the debugger?), but it doesn’t look like you need to use the Select command in this instance.
[quote=181438:@JrmeLeray]Hi everyone,
Can you help me with this wrong Excel automation code ?
excel.Range(“E:M”).Select_
excel.Selection.ColumnWidth = 15
excel.Selection.WrapText = True
excel.Selection.HorizontalAlignment= Office.xlCenter
Debugger Issue : “excel.Selection.HorizontalAlignment= Office.xlCenter” - This item does not exist
Thanks for your help
Jrme[/quote]
This code works perfectly on desktop version, but not with web edition.
It may be that the enumerations are not available in the web edition.
Try using the integer equivalent:
excel.Selection.HorizontalAlignment = -4108
[quote=181662:@Mark Walsh]It may be that the enumerations are not available in the web edition.
Try using the integer equivalent:
excel.Selection.HorizontalAlignment = -4108[/quote]
Great, that’s works perfectly
Thanks a lot !