2015-02-12 15 views
0

因此,我在上一个问题中找到了这个惊人的答案,我只是想知道如何在指定位置启动搜索窗口 - 保存它们必须搜索尽管每次都有多个文件夹。对不起,我不能回复原来的帖子,自从我创建了我的帐户以来,我有1个声望。从名称不同的其他工作簿中获取数据 - 要求用户选择它们

请帮忙! 谢谢,

显式的选项

Sub Sample() 
    Dim wb1 As Workbook, wb2 As Workbook 
    Dim Ret1, Ret2 

    Set wb1 = ActiveWorkbook 

    '~~> Get the first File 
    Ret1 = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*", _ 
    , "Please select first file") 
    If Ret1 = False Then Exit Sub 

    '~~> Get the 2nd File 
    Ret2 = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*", _ 
    , "Please select Second file") 
    If Ret2 = False Then Exit Sub 

    Set wb2 = Workbooks.Open(Ret1) 
    wb2.Sheets(1).Cells.Copy wb1.Sheets(1).Cells 
    wb2.Close SaveChanges:=False 

    Set wb2 = Workbooks.Open(Ret2) 
    wb2.Sheets(1).Cells.Copy wb1.Sheets(2).Cells 
    wb2.Close SaveChanges:=False 

    Set wb2 = Nothing 
    Set wb1 = Nothing 
End Sub 
+0

http://www.mrexcel.com/forum/excel-questions/574110-getopenfilename-default-directory.html – 2015-02-12 06:41:58

回答

0

解决。

对于任何需要解决方案的人来说,我通过在打开每个对话框之前设置目录的默认文件夹来解决问题。

CHDIR “C:\地方\ \我们隐藏\事情”

随后的对话框中打开代码。如果你需要更好的解释,你会发现一个魅力,评论。

相关问题