Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to open a csv file within Excel as a workbook. In the good
old days the simple Dim i As Integer Dim iNumRetries As Integer Dim wkbT As Workbook ' Explicitly initialize the return value Set openCSVFile = Nothing ' Read how many times to try iNumRetries = U_System.Range("rngNumCSVRetries").Value ' If you can't open it then try, try again -- up to the limit 'On Error Resume Next For i = 1 To iNumRetries Set wkbT = Workbooks.Open(psRawName) ', 0, True, 6, , True, , Chr(9)) If Not (wkbT Is Nothing) Then Exit For End If Next Set openCSVFile = wkbT worked fine. And it still does, it I walk through the code (e.g. F8). However if the macro is called from either the ribbon or the immediate window, Excel crashes at the Workbooks.Open() statement. And 'crashes' in the sense of the pop-ups "Microsoft Excel has stopped working .... is trying to recover your information ..." Changing the code to be much more explicit, i.e. Workbooks.OpenText Filename:=psRawName, origin:=xlWindows, StartRow:=1, _ DataType:=xlDelimited, TextQualifier:=xlTextQualifierNone, ConsecutiveDelimiter:=False, _ Tab:=False, Semicolon:=False, Comma:=True, Space:=False, Other:=False results in the same behavior. The file being opened is a plain vanilla, nothing special, no weird characters, comma delimited file. So I'm stumped. Anyone know why F8-ing through the code works but letting it run as a full macro fails? Even better, any ideas on how to fix the issue? = M = |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can't open workbook in excel 64 bit 2010 - but can in excel 2010 3 | Excel Programming | |||
Excel crashes when I open the file, except..... | Excel Programming | |||
Excel 2007 crashes when I open a file with vba code | 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 |