打开Excel模板(xltx)作为Excel模板而不是工作簿 [英] Opening an Excel Template (xltx) as an Excel Template not a workbook

查看:484
本文介绍了打开Excel模板(xltx)作为Excel模板而不是工作簿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写一行代码以将excel模板(xltx)文件作为excel模板文件而不是新工作簿打开.

I am trying to write a line of code to open an excel template (xltx) file as an excel template file not a new workbook.

我只想允许用户查看和编辑他们在我们网络上的库文件夹中拥有的模板.

I simply want to allow users to view and edit the templates they've side in a library folder on our network.

但是,我尝试过的所有操作都会打开一个新的工作簿,而不是一个模板.

However everything I've tried opens a new workbook not a template.

我尝试了互操作:

Workbooks.Open(selectedxltxFile, Missing.Value, Missing.Value, Excel.XlFileFormat.xlOpenXMLTemplate, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

以及Process.Start方法:

and also the Process.Start method:

System.Diagnostics.Process.Start(@"C:\MYTemnplate.xltx")

这甚至有可能还是我吠错了树吗?

Is this even possible or am I barking up the wrong tree?

推荐答案

Workbooks.Open(Filename: @"C:\MYTemnplate.xltx", Editable: true);

我在任何地方都找不到.当所有其他方法都失败时(这很不好),记录一个宏,其中包含您要完成的操作,然后查看生成的VBA.

I couldn't find this anywhere. When all else fails (this isn't pretty) record a macro containing the action you're trying to accomplish, and then look at the generated VBA.

来自文档:

可编辑

类型:System.Object

Type: System.Object

可选对象.如果文件是Microsoft Excel 4.0加载项,则此参数为True以打开加载项,以便它是可见窗口.如果此参数为False或被省略,则外接程序将以隐藏状态打开,并且无法取消隐藏.此选项不适用于在Microsoft Excel 5.0或更高版本中创建的加载项. 如果文件是Excel模板,请使用True打开指定的模板进行编辑,或使用False打开基于指定模板的新工作簿.默认值为False.

Optional Object. If the file is a Microsoft Excel 4.0 add-in, this argument is True to open the add-in so that it’s a visible window. If this argument is False or omitted, the add-in is opened as hidden, and it cannot be unhidden. This option doesn't apply to add-ins created in Microsoft Excel 5.0 or later. If the file is an Excel template, use True to open the specified template for editing or False to open a new workbook based on the specified template. The default value is False.

换句话说,此参数可以根据上下文表示不同的含义,并且都不是直观的.如果指定Editable: false,则将基于模板打开一个新的工作簿.它可以编辑吗?是的.

In other words, this parameter can mean different things depending on the context, and none of them are intuitive. If you specify Editable: false then a new workbook is opened based on the template. Is it editable? Yes.

这篇关于打开Excel模板(xltx)作为Excel模板而不是工作簿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆