Workbooks.Open always have

M

moonhk

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
 
G

GS

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top