Excel VBA - 运行宏/打开另一个文件/运行该文件宏/ Save&关 [英] Excel VBA - Run Macro / Open another file / Run that files macro / Save & Close

查看:1385
本文介绍了Excel VBA - 运行宏/打开另一个文件/运行该文件宏/ Save&关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我想要做的。


  • 在文件x中运行宏

  • 文件x宏打开文件y

  • 然后调用文件y的宏

  • 文件y的宏运行

  • 文件y关闭

  • Run macro in file x
  • File x macro opens file y
  • Then calls file y's macro
  • File y's macro runs
  • File y closes

目前,我正在从文件x的宏中打开文件y,但是一旦文件y为打开,并且不会过去打开。

Currently, I'm getting as far as opening file y from file x's macro, but the macro ends once file y is open and doesn't step through past opening.

我看了一下,尝试使用这个线程的信息在多个文件上运行excel宏,但没有帮助。

I had a look and attempted using info from this thread Run excel macro on multiple files, but it didn't help.

欣赏任何人都可以提供任何帮助。

Appreciate any help anyone can offer.

这是我的代码在结束之前得到的一部分。这将打开文件y,但会结束宏;

Here is the part of my code it gets to before ending. This opens file y, but ends the macro;

Workbooks.Open (MyPath & FileY & ".xls")

我想让宏执行此操作;

I want the macro to then do this;

ActiveWorkbook.Application.Run FileYsMacro

谢谢。 p>

Thanks.

推荐答案

不要使用ActiveWorkbook。使用:

Don't use ActiveWorkbook. Use:

 Workbooks("WorkbookName").Application.Run

这篇关于Excel VBA - 运行宏/打开另一个文件/运行该文件宏/ Save&关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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