Chr(charcode)
使用 win32ole 从 Ruby调用 VBScript 函数(例如 VBScript's )是否可行?
背景:在研究如何在 Excel 工作表中添加一些格式良好的标题时,我遵循了我的标准操作程序:记录一个 Excel 宏并复制并粘贴代码。
VB脚本:
ActiveWindow.View = xlPageLayoutView
With ActiveSheet.PageSetup
' Irrelevant options snipped
.CenterHeader = "&F" & Chr(10) & "&A"
' More irrelevant options snipped
End With
以下 Ruby 代码
# workbook is an existing workbook object
worksheet = workbook.Worksheets.Add
worksheet.PageSetup.CenterHeader = "&F \n &A"
有效,但我必须查看Chr(charcode)
文档以检查它是否完全相同。我试着做
worksheet.PageSetup.CenterHeader = "&F" + workbook.Chr(10) + "&A"
但得到了
WIN32OLERuntimeError: unknown property or method: `Chr'
HRESULT error code:0x80020006
Unknown name.
from (irb):6:in `method_missing'
from (irb):6
from c:/Ruby19/bin/irb:12:in `<main>'
后一种方法有什么实用的方法吗?