View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Workbooks.Open always have

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