基于VBA中的模板创建新的Excel文件 [英] Creating a new Excel File based on a template in VBA

查看:247
本文介绍了基于VBA中的模板创建新的Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Excel中构建一个应用程序,它将使用户能够从已构建的现有基于excel的工具列表中进行选择.他们将选择特定的工具,然后单击创建新"按钮.单击此按钮后,将要求用户命名文件.输入名称后,需要创建一个新的工作簿并将其放置在该特定工具的项目文件夹中.我无法在代码中实现此功能.我已经能够从活动工作簿中找到实现复制模板的代码示例,但是无法完全在另一个excel文件中创建内容.

I am building an application in Excel which will enable a user to select from a list of existing excel based tools that have been built. They will select the specific tool and hit a "create new" button. Upon clicking this button, the user will be asked to name the file. After entering the name, a new workbook needs to be created and placed in that specific tool's project folder. I am having trouble implementing this in code. I have been able to find examples of code implementing copying templates from the active workbook, but nothing for creating something that is in another excel file entirely.

我相信我需要复制用户需要重新创建的工作簿,然后更改名称并将文件放置在所需的位置.

I believe I need to make a copy of the workbook that the user needs to recreate and then change the name and place the file in the desired location.

我会发布一些代码来显示到目前为止的工作,但是我并没有真正取得进展.

I would post some code to show what I've done so far, but I haven't really made progress.

谢谢

推荐答案

set wb = workbooks.add("x:\mytemplate.xls")允许您创建新文档并指定要用作模板的文件.

set wb = workbooks.add("x:\mytemplate.xls") allows you to create a NEW doc and specify the file to be used as a template.

这篇关于基于VBA中的模板创建新的Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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