Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jat jat is offline
external usenet poster
 
Posts: 33
Default Workbooks.open method fails

Hi,

I am trying to open an Excel spreadsheet from Access using the following
code in Access:

Private mobjXL As Excel.Application

Private Sub cmdImportFiles_Click()
Dim wrk As Excel.Workbook
Set mobjXL = New Excel.Application
With mobjXL
.ScreenUpdating = False
.Visible = false
.DisplayAlerts = False
Set wrk = mobjXL.Workbooks.Open("Excel file path and name")
' Do something with the Excel spreadsheet
End With
' error handler
End Sub

I keep getting an error message of 'Method 'Open' of object Workbook failed'
everytime Excel tries to open the spreadsheet (and it can be any
spreadsheet). Any suggestions on how to open the Excel spreadsheet in VBA
without the error message?

Regards
Justin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Workbooks.open method fails

Your code looks okay, although it doesn't look as if you copied in the real
code since the "false" after .Visible is not proper case.
You are specifying an existing file along with an extension? Like
"c:\MyPath\MyFile.xls"

--
Jim Rech
Excel MVP
"JAT" wrote in message
...
| Hi,
|
| I am trying to open an Excel spreadsheet from Access using the following
| code in Access:
|
| Private mobjXL As Excel.Application
|
| Private Sub cmdImportFiles_Click()
| Dim wrk As Excel.Workbook
| Set mobjXL = New Excel.Application
| With mobjXL
| .ScreenUpdating = False
| .Visible = false
| .DisplayAlerts = False
| Set wrk = mobjXL.Workbooks.Open("Excel file path and name")
| ' Do something with the Excel spreadsheet
| End With
| ' error handler
| End Sub
|
| I keep getting an error message of 'Method 'Open' of object Workbook
failed'
| everytime Excel tries to open the spreadsheet (and it can be any
| spreadsheet). Any suggestions on how to open the Excel spreadsheet in VBA
| without the error message?
|
| Regards
| Justin


  #3   Report Post  
Posted to microsoft.public.excel.programming
jat jat is offline
external usenet poster
 
Posts: 33
Default Workbooks.open method fails

Jim thank you for your reply,

I am using the full path with the file extension. The code is just a summary
of my full code. I am trying to convert some Excel files into a text file so
they can be imported into a SQL server database using a DTS package.

The files I get from a client and they always seem to have been corrupted
and recovered by Excel at the clients end as I get a message when I open them
in Excel telling me this. The DTS package won't accept the Excel files
because of this message that pops up when the file is imported, hence the
conversion to a text file.

I was hoping to be able to get Excel to open the files without the message
(hence DisplayAlerts=False) and convert them to a text file. Any suggestions
on how to open the files without the recovery warning messages as it seems to
be this message that is giving me the problems?

Justin


"Jim Rech" wrote:

Your code looks okay, although it doesn't look as if you copied in the real
code since the "false" after .Visible is not proper case.
You are specifying an existing file along with an extension? Like
"c:\MyPath\MyFile.xls"

--
Jim Rech
Excel MVP
"JAT" wrote in message
...
| Hi,
|
| I am trying to open an Excel spreadsheet from Access using the following
| code in Access:
|
| Private mobjXL As Excel.Application
|
| Private Sub cmdImportFiles_Click()
| Dim wrk As Excel.Workbook
| Set mobjXL = New Excel.Application
| With mobjXL
| .ScreenUpdating = False
| .Visible = false
| .DisplayAlerts = False
| Set wrk = mobjXL.Workbooks.Open("Excel file path and name")
| ' Do something with the Excel spreadsheet
| End With
| ' error handler
| End Sub
|
| I keep getting an error message of 'Method 'Open' of object Workbook
failed'
| everytime Excel tries to open the spreadsheet (and it can be any
| spreadsheet). Any suggestions on how to open the Excel spreadsheet in VBA
| without the error message?
|
| Regards
| Justin



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Workbooks.open method fails

Sorry Justin, I don't know how to turn off this error message. Very strange
that you always have this problem with this client's files. Investigating
that problem is the next step I think.

--
Jim Rech
Excel MVP
"JAT" wrote in message
...
| Jim thank you for your reply,
|
| I am using the full path with the file extension. The code is just a
summary
| of my full code. I am trying to convert some Excel files into a text file
so
| they can be imported into a SQL server database using a DTS package.
|
| The files I get from a client and they always seem to have been corrupted
| and recovered by Excel at the clients end as I get a message when I open
them
| in Excel telling me this. The DTS package won't accept the Excel files
| because of this message that pops up when the file is imported, hence the
| conversion to a text file.
|
| I was hoping to be able to get Excel to open the files without the message
| (hence DisplayAlerts=False) and convert them to a text file. Any
suggestions
| on how to open the files without the recovery warning messages as it seems
to
| be this message that is giving me the problems?
|
| Justin
|
|
| "Jim Rech" wrote:
|
| Your code looks okay, although it doesn't look as if you copied in the
real
| code since the "false" after .Visible is not proper case.
| You are specifying an existing file along with an extension? Like
| "c:\MyPath\MyFile.xls"
|
| --
| Jim Rech
| Excel MVP
| "JAT" wrote in message
| ...
| | Hi,
| |
| | I am trying to open an Excel spreadsheet from Access using the
following
| | code in Access:
| |
| | Private mobjXL As Excel.Application
| |
| | Private Sub cmdImportFiles_Click()
| | Dim wrk As Excel.Workbook
| | Set mobjXL = New Excel.Application
| | With mobjXL
| | .ScreenUpdating = False
| | .Visible = false
| | .DisplayAlerts = False
| | Set wrk = mobjXL.Workbooks.Open("Excel file path and
name")
| | ' Do something with the Excel spreadsheet
| | End With
| | ' error handler
| | End Sub
| |
| | I keep getting an error message of 'Method 'Open' of object Workbook
| failed'
| | everytime Excel tries to open the spreadsheet (and it can be any
| | spreadsheet). Any suggestions on how to open the Excel spreadsheet in
VBA
| | without the error message?
| |
| | Regards
| | Justin
|
|
|


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
Office Web Components: No Open Method of Workbooks? Karl Yates Excel Programming 1 December 18th 04 01:45 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
troubles with the Workbooks.Open method in Excel 97 Amarth Excel Programming 1 June 14th 04 02:02 PM
Open method of workbooks fails when Excel is hosted in IE [email protected] Excel Programming 5 January 30th 04 02:19 AM
Workbooks.Open fails after upgrade to XL2000 from XL97 Dan Merchant Excel Programming 0 July 9th 03 11:03 PM


All times are GMT +1. The time now is 12:35 PM.

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

About Us

"It's about Microsoft Excel"