admin管理员组文章数量:1026989
I want to automize some format work in one of my excel files. Therefore I used macros for a long time - now it's time to move to scripts I thought.
In the old world the cutsom style formating was done the following way:
With Range(SB_TABLE_NAME + "[Menge Geliefert]")
.NumberFormat = "## \Stk\."
End With
With scripts its nearly the same
cellColumn = sbOrderTable.getColumnByName("Menge Geliefert").getRange()
cellColumn.setNumberFormatLocal("## \S\tk\.");
I also used the recording to be sure the number format is correct (!) but as soon as I do run the script I get the following error: Range setNumberFormatLocal: The argument is invalid, missing, or in incorrect format.
Do anyone has an idea why the recording is storing the user defined format but the running script failes with it? I also used the getNumberFormatLocal() to get the current formating - result: "## \S\tk." - so I get a little confused...
As described I wanted to set a range of cells (a column in a table) to a specifig fomrat.
I want to automize some format work in one of my excel files. Therefore I used macros for a long time - now it's time to move to scripts I thought.
In the old world the cutsom style formating was done the following way:
With Range(SB_TABLE_NAME + "[Menge Geliefert]")
.NumberFormat = "## \Stk\."
End With
With scripts its nearly the same
cellColumn = sbOrderTable.getColumnByName("Menge Geliefert").getRange()
cellColumn.setNumberFormatLocal("## \S\tk\.");
I also used the recording to be sure the number format is correct (!) but as soon as I do run the script I get the following error: Range setNumberFormatLocal: The argument is invalid, missing, or in incorrect format.
Do anyone has an idea why the recording is storing the user defined format but the running script failes with it? I also used the getNumberFormatLocal() to get the current formating - result: "## \S\tk." - so I get a little confused...
As described I wanted to set a range of cells (a column in a table) to a specifig fomrat.
Share Improve this question asked Nov 18, 2024 at 16:11 PascalPascal 31 bronze badge1 Answer
Reset to default 0The backslash in ## \Stk\.
is an escape character. Pls change it to !
in OfficeScript.
cellColumn.setNumberFormatLocal("## !Stk!.");
Pls try below code, it creates same number format ## !Stk!.
on my pc.
selectedSheet.getRange("a1").setNumberFormatLocal("## \\S\\tk\\.");
I want to automize some format work in one of my excel files. Therefore I used macros for a long time - now it's time to move to scripts I thought.
In the old world the cutsom style formating was done the following way:
With Range(SB_TABLE_NAME + "[Menge Geliefert]")
.NumberFormat = "## \Stk\."
End With
With scripts its nearly the same
cellColumn = sbOrderTable.getColumnByName("Menge Geliefert").getRange()
cellColumn.setNumberFormatLocal("## \S\tk\.");
I also used the recording to be sure the number format is correct (!) but as soon as I do run the script I get the following error: Range setNumberFormatLocal: The argument is invalid, missing, or in incorrect format.
Do anyone has an idea why the recording is storing the user defined format but the running script failes with it? I also used the getNumberFormatLocal() to get the current formating - result: "## \S\tk." - so I get a little confused...
As described I wanted to set a range of cells (a column in a table) to a specifig fomrat.
I want to automize some format work in one of my excel files. Therefore I used macros for a long time - now it's time to move to scripts I thought.
In the old world the cutsom style formating was done the following way:
With Range(SB_TABLE_NAME + "[Menge Geliefert]")
.NumberFormat = "## \Stk\."
End With
With scripts its nearly the same
cellColumn = sbOrderTable.getColumnByName("Menge Geliefert").getRange()
cellColumn.setNumberFormatLocal("## \S\tk\.");
I also used the recording to be sure the number format is correct (!) but as soon as I do run the script I get the following error: Range setNumberFormatLocal: The argument is invalid, missing, or in incorrect format.
Do anyone has an idea why the recording is storing the user defined format but the running script failes with it? I also used the getNumberFormatLocal() to get the current formating - result: "## \S\tk." - so I get a little confused...
As described I wanted to set a range of cells (a column in a table) to a specifig fomrat.
Share Improve this question asked Nov 18, 2024 at 16:11 PascalPascal 31 bronze badge1 Answer
Reset to default 0The backslash in ## \Stk\.
is an escape character. Pls change it to !
in OfficeScript.
cellColumn.setNumberFormatLocal("## !Stk!.");
Pls try below code, it creates same number format ## !Stk!.
on my pc.
selectedSheet.getRange("a1").setNumberFormatLocal("## \\S\\tk\\.");
本文标签: Error on numberFormatLocal on Office ScriptsStack Overflow
版权声明:本文标题:Error on numberFormatLocal on Office Scripts - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745608764a2158881.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论