Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用OpenFile (指定编码)打开部分损坏的文件时,没有选项可以强制使用指定的编码,因此宏被中断。
宏中是否有一个选项可以强制它“继续作为当前编码打开”,而不是让用户选择并继续?
您可以在文件类型的配置属性的文件页面中清除“发现空字符时提示”和“发现无效字符时提示”选项。要在宏中执行此操作,您可以在OpenFile之前添加以下代码。
document.ConfigName = "Text"; // replace "Text" with the configuration of your file type cfg = document.Config; cfg.File.PromptInvalid = false; cfg.File.PromptNull = false; cfg.Save();