Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All
Excel 2007 Sub OpenFile_USER_LIST() On Error Resume Next Dim i As Integer Dim returnValue As Workbook returnValue = Workbooks.Open(Filename:="D:\files\User_List.xlsx" ) End Sub When Run above code prompted "Code execution has been interruped" . Why this happened ? This worksheet without any VBA. End Sub <---- Error here This procedure called by Menu Command or run in Modules. Run 2nd/3rd time have error Code execution has been interruped |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
moonhk pretended :
Hi All Excel 2007 Sub OpenFile_USER_LIST() On Error Resume Next Dim i As Integer Dim returnValue As Workbook returnValue = Workbooks.Open(Filename:="D:\files\User_List.xlsx" ) End Sub When Run above code prompted "Code execution has been interruped" . Why this happened ? This worksheet without any VBA. End Sub <---- Error here This procedure called by Menu Command or run in Modules. Run 2nd/3rd time have error Code execution has been interruped You're missing a 'Set' statement. This is required to put a ref to the workbook being opened into your variable. *However*, this is all you really need... Sub OpenFile_USER_LIST() Workbooks.Open "D:\files\User_List.xlsx" End Sub ...though I absolutely do not understand why you need a dedicated procedure for this when the single line of code could be used anywhere needed without making a call to an outside procedure. -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel2007; workbooks.count is not counting all open workbooks | Excel Programming | |||
VBA Excel.WorkBooks.Open can't open an XML format xls file | Excel Programming | |||
workbooks.open function fails to open an existing excel file when used in ASP, but works in VB. | Excel Programming | |||
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed | Excel Programming | |||
Workbooks.Open / .Open Text - How do you stop the .xls addition? | Excel Programming |