宏将VB代码从一个工作表复制到另一个工作表 [英] Macro to copy VB code from one worksheet to another

查看:793
本文介绍了宏将VB代码从一个工作表复制到另一个工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


我想在Excel电子表格中使用自定义文档属性。根据我的理解,我不能像在MS Word中那样直接引用属性,而是每次都必须调用一个函数。我有一个工作代码,但
我的问题是如何将此代码复制到新文档。


在工作中我们正在使用Word管理长列表而我我们的任务是调查我们是否可以将这些列表移到Excel中以简化操作。每个文件都必须在我们的文档管理系统中注册,以便跟踪它们。创建新的
文件时,DMS会填充某些自定义文档属性,我希望使用这些属性来防止用户忘记编辑某些值(例如作者姓名,文档标题和版本等)。


所有这些列表看起来都一样,我创建了一个模板布局。不幸的是,IT部门不允许我将此模板注册为新文件的DMS模板,因此每个用户都必须打开我的模板文件并将整个内容复制到他们的
新文件中,但我无法问他们打开VB编辑器并将模板文件中的代码复制到新文档。


为了简化操作,我正在考虑创建一个宏来处理这个以及启用自定义然后,文档属性和用户只需单击将运行所有代码的单个按钮。但是,我还没弄明白如何
将自定义文档属性代码复制到新文件中。


有没有人可以帮助我?


我们正在运行Excel 2010.

解决方案

保存文件作为一个启用宏的寺庙(.xltm) - 那么代码(和自定义文档属性)将驻留在用户保存文件时创建的Excel文件中 - 覆盖DMS创建的文件...应该是允许的。

Hello

I would like to use custom document properties in an Excel spreadsheet. From what I understand, I can't reference the properties directly like one would do in MS Word but instead I have to call a function each time. I have a working code for this but my problem is how to copy this code to new documents.

At work we're currently using Word to manage long lists and I have been tasked to investigate if we can move these lists to Excel instead to simplify things. Each file has to be registered in our document management system to keep track of them. When a new file is created, certain custom document properties are populated by the DMS and I would like to use these properties to prevent users from forgetting to edit certain values (such as author name, document title and version etc).

All these lists look the same and I have created a template layout. Unfortunately the IT department won't let me register this template as a DMS template for new files so each user will have to open my template file and copy the entire contents to their new file but there is no way I could ask them to open the VB editor and copy code from the template file to the new document.

To simplify things I was thinking about creating a macro that takes care of this as well as enabling the Custom document properties and the users would then only click a single button that would run all code. However, I have yet to figure out how to copy the Custom document properties code to the new file.

Is there anyone who can help me?

We're running Excel 2010.

解决方案

Save your file as a macro-enabled temple (.xltm) - then the code (and the custom document properties) will reside in the Excel file that is created when the user saves the file - overwriting the file that your DMS created... that should be allowed.


这篇关于宏将VB代码从一个工作表复制到另一个工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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