Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Workbooks.Open always have

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   Report Post  
Posted to microsoft.public.excel.programming
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel2007; workbooks.count is not counting all open workbooks greg.campeau Excel Programming 2 August 2nd 08 08:37 PM
VBA Excel.WorkBooks.Open can't open an XML format xls file giantdino Excel Programming 2 August 14th 07 03:12 PM
workbooks.open function fails to open an existing excel file when used in ASP, but works in VB. san Excel Programming 1 January 3rd 06 03:22 AM
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 Frank Jones Excel Programming 2 June 15th 04 03:21 AM
Workbooks.Open / .Open Text - How do you stop the .xls addition? Dave[_20_] Excel Programming 2 July 31st 03 04:03 AM


All times are GMT +1. The time now is 10:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"