创建新工作簿会生成我不理解的错误代码 [英] Creating new workbook generates an error code I don't understand
问题描述
在Excel 2003中使用VBA....我有以下几行:
子示例
将OldWorkBookName设置为字符串
OldWorkBookName ="new. xls"
将NewWorkBook设置为工作簿
设置NewWorkBook = Workbooks.add(Template:= OldWorkBookName)
end Sub
当我使用编辑器通过上述设置"的单个步骤.命令,我收到以下消息:"OldWorkBookName已经打开.重新打开将导致更改被放弃.
我对为什么会遇到此错误感到困惑.我看不到我如何重新开放".除NewWorkBook以外的任何文件,我显然都没有将其另存为文件.我只是基于原始工作簿(OldWorkBookName)中的数据创建对新工作簿的引用.当然文件(OldWorkBook)是打开的...它包含我的宏.如果我关闭文件(Workbooks(OldWorkbook).close),屏幕将变为空白(vba实际上关闭了文件).
请帮忙.
您可以在此处发帖,也可以通过 whburling@earthlink.net
Using VBA in Excel 2003....i have the following lines:
Sub example
Dim OldWorkBookName as string
OldWorkBookName = "new.xls"
Dim NewWorkBook as workbook
Set NewWorkBook = Workbooks.add(Template:=OldWorkBookName)
end Sub
When I use the editor to single step through the above "set" command, I get the following message: "OldWorkBookName is already open. Reopening will cause changes to be discarded.
I am confused as to why I should encounter this error. I don't see how I am "reopening" any file but maybe the NewWorkBook which I clearly have not saved as a file(yet). I am merely creating a reference to a new workbook based upon the data within the original workbook(OldWorkBookName). Of course the file(OldWorkBook) is open....it contains my macros. If I close the file (Workbooks(OldWorkbook).close) the screen goes blank (vba actually closes the file).
Please help.
You can either post here or send to me at whburling@earthlink.net
Bil
推荐答案
比尔,
这是一个有关使用Visual Basic语言的论坛,甚至不是有关如何使用VB的论坛.
但是两个论坛都仅限于VB for Net,因此,您有以下机会获得更好的答案:
http://social.msdn.microsoft.com/forums/en-US/isvvba/threads/
这篇关于创建新工作簿会生成我不理解的错误代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!