![]() |
Universal open
Inside a folder, I have several workbooks that are linked. I have
recorded a macro to open them in sequence and it works fine, but I does not work if I move the whole folder. The code I use is - Workbooks.Open Filename:= _ "xxx:xxx.xls" How can I fix this? Is there a solution that will travel with the location of the folder? |
Universal open
Is your macro in the same folder as the other workbooks ?
If yes, you cld use something like this. Workbooks.Open (ThisWorkbook.Path & "\" & "xxx.xls") If No, You need to provide a way for the macro to knw where the files are stored. Mulitple ways to do this. Try the foll below. Sub FolderPath() Dim FolderDestn As String With Application.FileDialog(msoFileDialogFolderPicker) If .Show = -1 Then FolderDestn = .SelectedItems(1) Else FolderDestn = vbNullString End If End With Workbooks.Open (FolderDestn & "\" & "xxx.xls") End Sub HTH, -- Tausif Mohammed "Geri" wrote: Inside a folder, I have several workbooks that are linked. I have recorded a macro to open them in sequence and it works fine, but I does not work if I move the whole folder. The code I use is - Workbooks.Open Filename:= _ "xxx:xxx.xls" How can I fix this? Is there a solution that will travel with the location of the folder? |
All times are GMT +1. The time now is 04:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com