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

Please help,

When I attempt to use the Excel workbook open method with
options in MS Access, I get an error message saying it
can't find the file.
I want to programmatically open an excel file that is
password protected and daily transfer this file to
Access. (I have the password).


Dim xlapp As Excel.Application
Dim xlworkbook As Excel.Workbooks
Dim strFileName As String

Set xlapp = CreateObject("Excel.application")
xlapp.Workbooks.Open ("strfilename,,,password")
xlapp.Visible = True
DoCmd.TransferSpreadsheet acImport,
acSpreadsheetTypeExcel97, tbl1, strFileName

xlapp.Quit
Set xlapp = Nothing

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Workbook Open method

Gwen,

Change
xlapp.Workbooks.Open ("strfilename,,,password")
to
xlapp.Workbooks.Open strfilename,,,password ' no quotes or
parens


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Gwen" wrote in message
...
Please help,

When I attempt to use the Excel workbook open method with
options in MS Access, I get an error message saying it
can't find the file.
I want to programmatically open an excel file that is
password protected and daily transfer this file to
Access. (I have the password).


Dim xlapp As Excel.Application
Dim xlworkbook As Excel.Workbooks
Dim strFileName As String

Set xlapp = CreateObject("Excel.application")
xlapp.Workbooks.Open ("strfilename,,,password")
xlapp.Visible = True
DoCmd.TransferSpreadsheet acImport,
acSpreadsheetTypeExcel97, tbl1, strFileName

xlapp.Quit
Set xlapp = Nothing



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Workbook Open method

Hi Gwen,

Get rid of the double quotes around the arguments to the Workbooks.Open
method:

xlapp.Workbooks.Open ("strfilename,,,password")

should be

xlapp.Workbooks.Open (strFileName,,,"password")

I'm assuming "password" is a literal string here. If it's a constant or
variable, get rid of the double quotes around it too.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Gwen" wrote in message
...
Please help,

When I attempt to use the Excel workbook open method with
options in MS Access, I get an error message saying it
can't find the file.
I want to programmatically open an excel file that is
password protected and daily transfer this file to
Access. (I have the password).


Dim xlapp As Excel.Application
Dim xlworkbook As Excel.Workbooks
Dim strFileName As String

Set xlapp = CreateObject("Excel.application")
xlapp.Workbooks.Open ("strfilename,,,password")
xlapp.Visible = True
DoCmd.TransferSpreadsheet acImport,
acSpreadsheetTypeExcel97, tbl1, strFileName

xlapp.Quit
Set xlapp = Nothing



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
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
Open method of workbooks fails when Excel is hosted in IE [email protected] Excel Programming 5 January 30th 04 02:19 AM
EXCEL.exe stays open after Quit method in an HTA myriams9 Excel Programming 5 December 4th 03 07:06 AM
Open Method of workbooks class failed kiran[_2_] Excel Programming 0 November 6th 03 09:58 PM
Open Method disabling Macros Bryan Steffen Excel Programming 0 July 16th 03 01:34 PM


All times are GMT +1. The time now is 07:12 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"