2015-02-12 16 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:\地方\ \我們隱藏\事情」

隨後的對話框中打開代碼。如果你需要更好的解釋,你會發現一個魅力,評論。

相關問題