3

I'm using a macro to create a CNC program.
To create the ".spf" file the machine is using I use:

Dim m2_path as string
m2_path = T:\Production\Cavity-Line\Eric R\Excel\PARAMETER.spf

Dim text as string
text = 'my data

Dim fso As Object
Dim Fileout As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set Fileout = fso.CreateTextFile(m2_path, True, True)
Fileout.Write text
Fileout.Close

When I try to open the program on the machine I get a error "Cannot open binary files".
But If I manually copy the content from the "m2_path"-file into another one and then try to open it, I don't get the error message.

Is there something wrong with the formatting of the text file?

Machine is using SINUMERIK 840d sl.

Thanks in advance
Regards

EDIT:
Thanks to @ashleedawg

4

1 回答 1

3

很高兴听到您的更改取得了成功:

从 :

Set Fileout = fso.CreateTextFile(m2_path, True, True) 

至 :

Set Fileout = fso.CreateTextFile(m2_path, True, False)

创建 ASCII 文件而不是 Unicode(机器无法读取)。

参考西门子 SINUMERIK 840D sl CNC 软件 2.6 SP1 HF4 安装/操作手册,第 29 页

如果文本文件使用 LF 字符 (0aH) 或字符串 CRLF (0d0aH) 作为行或程序段标识符,则可以使用 SINUMERIK Operate Editor 编辑文本文件。编辑器无法打开二进制文件。... 从 SINUMERIK Operate Editor 新生成的文件采用 UTF-8 编码 - 并以 LF 字符作为块标识符的结尾。对于 UTF-8 编码的文件,所有特殊字符都会正确显示。打开文件时,SINUMERIK Operate Editor 假定文件是 UTF-8 编码的。如果打开具有其他编码的文件,例如使用 Windows 页面编码,则只有在将 SINUMERIK Operate 更改为相应的系统语言时才能正确显示特殊字符。这也涉及例如使用 HMI 高级编辑器生成的文件。使用 SINUMERIK Operate Editor 打开时,这些文件的编码不会改变。没有自动转换为 UTF-8 编码。如果我们使用外部编辑器(例如 Windows 下的记事本)而不是 SINUMERIK Operate Editor 生成或处理文件,则应注意文件以 UTF-8 编码保存。使用记事本时,将文件另存为编码时,在“另存为”对话框中选择“UTF-8”。如果不使用特殊字符,则“ANSI”也可以指定为编码。UTF-8 编码。使用记事本时,将文件另存为编码时,在“另存为”对话框中选择“UTF-8”。如果不使用特殊字符,则“ANSI”也可以指定为编码。UTF-8 编码。使用记事本时,将文件另存为编码时,在“另存为”对话框中选择“UTF-8”。如果不使用特殊字符,则“ANSI”也可以指定为编码。

于 2017-11-19T07:30:39.490 回答