将“ThisWorkbook”宏导入另一个工作簿(Import “ThisWorkbook” macro to another Workbook)
我需要VBA代码将过程导入另一个工作簿中的
ThisWorkbook
范围。我有代码将模块导入另一个工作簿,但如何将此过程导入
ThisWorkbook
范围而不是模块范围?Sub TransferModule() Const modul As String = "Misc" Const tempfile As String = "/Users/Roman/Desktop/temp.bas" Dim WBK As Workbook On Error Resume Next Set WBK = Workbooks.Add ThisWorkbook.VBProject.VBComponents(modul).Export tempfile WBK.VBProject.VBComponents.Import tempfile Kill tempfile End Sub
这将从“This”工作簿中获取
Misc
模块,将其导出到temp.bas
,然后将其导入另一个工作簿。 但是我需要它不导入模块,而是导入ThisWorkbook
范围。 这是一个Private Sub Workbook_BeforeClose
事件。I need VBA code to import a procedure into
ThisWorkbook
scope within another workbook.I have code to import a module into another workbook, but how to import this procedure into
ThisWorkbook
scope instead of into a module scope?Sub TransferModule() Const modul As String = "Misc" Const tempfile As String = "/Users/Roman/Desktop/temp.bas" Dim WBK As Workbook On Error Resume Next Set WBK = Workbooks.Add ThisWorkbook.VBProject.VBComponents(modul).Export tempfile WBK.VBProject.VBComponents.Import tempfile Kill tempfile End Sub
This takes module
Misc
from "This" workbook, exports it totemp.bas
and then import it to another workbook. However I need it to import not into a module, but intoThisWorkbook
scope. It's aPrivate Sub Workbook_BeforeClose
event.
原文:https://stackoverflow.com/questions/46584030
最满意答案
Sasha在上面正确地指出我应该拥有完整的路径名。 一旦我补充说,我就不再看到这个错误了。 我自己回答这个问题要把它关掉。 请在上面提出Sasha的评论,以表示赞赏。 如果Sasha最终将评论作为答案发布,我将予以奖励。
Sasha correctly identified above that I should have had the full pathname. Once I added that, I ceased seeing this error. I am answering this question myself to close it out. Please upvote Sasha's comment above to give credit. If Sasha ends up posting the comment as an answer I will award it.
相关问答
更多-
使用os.pardir (可能总是".." ) import os fobj = open(os.path.join(os.pardir, "filename"), "w") Use os.pardir (which is probably always "..") import os fobj = open(os.path.join(os.pardir, "filename"), "w")
-
在Gradle构建脚本中使用纯粹的相对路径时要小心; 那些在调用构建时依赖于工作目录,这不是你应该依赖的东西。 将您的路径与$projectDir或$rootDir 。 尝试这样的事情: def file = new File("$projectDir/$folderName/my.properties"); 有关可以使用的变量列表,请参阅http://www.gradle.org/docs/current/dsl/org.gradle.api.Project.html 。 Be careful abou ...
-
没有这样的文件或目录,没有指向正确的文件 - Rails(No such file or directory, not pointing to the right file - Rails)[2022-09-19]
我会自己回答: 我不知道这个备份文件来自哪里,但我刚删除它们,然后重新启动服务器并重新开始工作! 感谢Max Williams的努力! I will answer myself: I don't know where this backup files came from, but I just removed them, and restart the server and all start working again! Thanks Max Williams for the effort! -
好先检查一下你是否安装了ruby和rails ruby -v 和 rails -v 因此,如果你得到回应,那么你就可以去你想要创建文件夹的地方 rails new appname 然后 cd appname 如果这不起作用尝试生成任何东西 rails generate controller appname 如果生成有效,那么你的rails就没问题了,那么你可能想要将rails添加到你的环境变量路径中。 您在计算机上安装了ruby。 但是,路径尚未被识别。 要添加它,您可以执行此操作。 如果 ...
-
糟糕的解释器:尝试创建Gemset后没有这样的文件或目录?(bad interpreter: No such file or directory after trying to create Gemset?)[2022-03-23]
您没有安装最新的ruby-2.0.0 。 您目前安装了ruby-2.0.0-p247 。 您将不得不指定要使用的修补程序级别。 在您的情况下,您可以使用命令, $ rvm use 2.0.0-p247@railstutorial_rails_4_0 --create --default 或者,我给你的建议,就是跑 $ rvm get latest $ rvm install ruby-2.0.0 这将安装最新的补丁级别,这将允许您以前的命令正常工作。 You do not have the latest ... -
在终端上创建如下符号链接: ln -s ./bin ./script 这是因为在Rails 4 script目录中已经移动到bin 。 Create a symbolic link as below on terminal: ln -s ./bin ./script This is because in Rails 4 script directory has been moved to bin.
-
Sasha在上面正确地指出我应该拥有完整的路径名。 一旦我补充说,我就不再看到这个错误了。 我自己回答这个问题要把它关掉。 请在上面提出Sasha的评论,以表示赞赏。 如果Sasha最终将评论作为答案发布,我将予以奖励。 Sasha correctly identified above that I should have had the full pathname. Once I added that, I ceased seeing this error. I am answering this que ...
-
if(is_dir("Server1/".$Key) === true){ header("Refresh:0"); } else { mkdir("Server1/".$Key); echo $Key; } 当目录"Server1/".$Key不存在但当目录Server1不存在时它也失败时,对is_dir()的调用失败。 另一方面,默认情况下, mkdir()在不存在时不会创建中间目录。 如果目录Server1不存在,则is_dir()返回FALSE , mkdir()失败,并显 ...
-
git和libgit:无法创建文件(没有这样的文件或目录)(git and libgit : unable to create file (No such file or directory))[2022-06-28]
$ git checkout a63cd37ef7d7228053b875e396531d367e2ea745 D "db\\32\\879a83081b8d0b4ef41a37b9e28138" 看到报价? git将使用C字符串文字约定来显示其中包含异常字符的文件名。 您的repo记录一个文件,其中包含该C字符串作为其名称 - 包含反斜杠。 : , \ ,和/无处不在, $ touch "db\\32\\879a83081b8d0b4ef41a37b9e28138" $ ls db\32\8 ... -
问题是tilde expansion不会发生,因为路径是变量值( tilde expansion发生在variable expansion之前)。 您可以使用$HOME而不是~来改善此问题。 那是 target_file="${HOME}/${source_file}" 这应该可以解决您的问题。 进一步阅读: man bash EXPANSION部分 The issue is that tilde expansion will not happen as the path is in a variable ...