使用 VB6 从模板创建后设置工作簿名称
我正在使用 VB6 程序从模板创建一个工作簿,如下所示:
set myWorkBook = myExcelApp.workbooks.Add(App.path & "\MyTemplate.xlt")
这将创建一个名为“MyTemplate1.xls”的工作簿。我希望工作簿名称更有意义。
我的问题是:有没有办法设置刚刚创建的工作簿的名称?
我知道我可以通过保存工作簿来做到这一点,但我不喜欢这种解决方案,我更喜欢用户决定是否真的要保留文件并按照自己的意愿命名。
I am creating a workbook from a template with my VB6 program, like this:
set myWorkBook = myExcelApp.workbooks.Add(App.path & "\MyTemplate.xlt")
This creates a workbook named "MyTemplate1.xls". I would like the workbook name to be more meaningful.
My question is: is there a way to set the name of this just created workbook?
I know I can do this by saving the workbook, but I don't like that solution, I prefer that the user decides if he really wants to keep the file and name it as he wants.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为有一种方法可以使用 Interop 设置工作簿名称而不保存,但根据您的描述,明显的解决方案是在打开模板文件之前将其复制到新的、更有意义的名称。这应该给你像 Meaning1 这样的名字,并不完美,但比 mytemplate1 更接近......
I think there's a way to set a workbook name using Interop without saving, but given your description the obvious solution is to copy the template file to your new, more meaningful name, before opening it. This should give you name like Meaning1, not perfect but much closer than mytemplate1...
如果用户决定不想保留它,您可以稍后将其删除。
You could just delete it later if the user decides they don't want to keep it.
您可以使用:
保存的完整选项是:
You may use:
The full option to save is: