如何在VBA中激活打开的Excel

时间:2018-02-23 13:38:06

标签: vba excel-vba excel

我有一个VBA代码,用于打开excel并执行自动过程。我的代码是

Dim strPath As String
Dim intChoice As Integer
intChoice = Application.FileDialog(msoFileDialogOpen).Show
If intChoice <> 0 Then
strPath = Application.FileDialog( _
msoFileDialogOpen).SelectedItems(1)

Workbooks.Open Filename:= _
    strPath

此过程在此完成,此过程在两个excel之间导航,一个包含宏,另一个包含数据。我们先说Excel A和Excel B. 我基于Excel A中的按钮在Excel B中执行自动化,然后从B中剪切数据并将其添加到A. 现在我的问题是包含数据的excel在名称上有所不同,所以我在代码中达到了这一点:

Windows("EPS.xlsx"). _
    Activate

我想要的地方&#34; EPS.xlsx&#34;要在我在本问题开头写的代码中由strPath打开的文件替换。

提前谢谢

0 个答案:

没有答案
相关问题