ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Open files from List (https://www.excelbanter.com/excel-discussion-misc-queries/238381-open-files-list.html)

jack

Open files from List
 
I'm trying to open a group of files from a list starting at D5 on the Menu
worksheet.
Following is the code i have tried.

sub open_files()
dim fname
With ActiveWorkbook
fname = "c:\documents\" & .worksheets("Menu").range("D5").value & ".xls"
Workbooks.Open Filename:= fname
End With
End Sub

the macro stops at the workbooks.open step - help would be appreciated

jasontferrell

Open files from List
 
This looks ok to me...what error are you getting? Do you have a
workbook with the right filename in the c:\documents directory?

jack

Open files from List
 
yes - the file is there - the error message i get is file can't be found

"jasontferrell" wrote:

This looks ok to me...what error are you getting? Do you have a
workbook with the right filename in the c:\documents directory?


jasontferrell

Open files from List
 
Change you code to add a msgbox that will display while running. Then
check the filename. You could've duplicated the "xls".

sub open_files()
dim fname
With ActiveWorkbook
fname = "c:\documents\" & .worksheets("Menu").range("D5").value &
".xls"
msgbox fname
Workbooks.Open Filename:= fname
End With
End Sub

Dave Peterson

Open files from List
 
If the workbook is opening, then the macro stops, change the shortcut key that
you use to run the macro. Do not include the shift key.

If the code stops before the workbook is opened, then what's the error? Maybe
you don't have a workbook with that name????



Jack wrote:

I'm trying to open a group of files from a list starting at D5 on the Menu
worksheet.
Following is the code i have tried.

sub open_files()
dim fname
With ActiveWorkbook
fname = "c:\documents\" & .worksheets("Menu").range("D5").value & ".xls"
Workbooks.Open Filename:= fname
End With
End Sub

the macro stops at the workbooks.open step - help would be appreciated


--

Dave Peterson

jack

Open files from List
 
Thanks

the file was a 2007 file - when i save it as a 2003 the macro worked.
thanks for your help

"jasontferrell" wrote:

Change you code to add a msgbox that will display while running. Then
check the filename. You could've duplicated the "xls".

sub open_files()
dim fname
With ActiveWorkbook
fname = "c:\documents\" & .worksheets("Menu").range("D5").value &
".xls"
msgbox fname
Workbooks.Open Filename:= fname
End With
End Sub


jack

Open files from List
 
Dave

thanks - i had the file as an excel 2007 once i changed it to 2003 this
worked.

"Dave Peterson" wrote:

If the workbook is opening, then the macro stops, change the shortcut key that
you use to run the macro. Do not include the shift key.

If the code stops before the workbook is opened, then what's the error? Maybe
you don't have a workbook with that name????



Jack wrote:

I'm trying to open a group of files from a list starting at D5 on the Menu
worksheet.
Following is the code i have tried.

sub open_files()
dim fname
With ActiveWorkbook
fname = "c:\documents\" & .worksheets("Menu").range("D5").value & ".xls"
Workbooks.Open Filename:= fname
End With
End Sub

the macro stops at the workbooks.open step - help would be appreciated


--

Dave Peterson


jack

Open files from List
 
What code do i need to add so that i don;t show the files as they are opening?

"jasontferrell" wrote:

Change you code to add a msgbox that will display while running. Then
check the filename. You could've duplicated the "xls".

sub open_files()
dim fname
With ActiveWorkbook
fname = "c:\documents\" & .worksheets("Menu").range("D5").value &
".xls"
msgbox fname
Workbooks.Open Filename:= fname
End With
End Sub


jasontferrell

Open files from List
 
You can add:
Application.ScreenUpdating=False
at the beginning and then set it to true at the end.

jack

Open files from List
 
Thanks for all your help

"jasontferrell" wrote:

You can add:
Application.ScreenUpdating=False
at the beginning and then set it to true at the end.



All times are GMT +1. The time now is 12:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com