Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel controlling Access controlling Excel!!!

Status
Not open for further replies.

RichF01

Technical User
Jun 6, 2005
14
GB
A brief overview of the system I am devloping is an Access data repository system, that feeds into Excel where the report writing is done. (I know Access can report write, but everyone who uses the system (including me) is happier with Excel).

I have a functioning Access system that automatically checks and imports the latest data on auto_open. This has built into it an Excel controlling system as there is data manipulation to be done before importing data and all the data feeds are Excel based.

I now want to control all of this from the Reporting end of the system (Excel). HOwever, I get the Excel Reporting code to open and run access OK, but then when Access opens Excel again it seems to open all the files in Read-Only Format, which is causing errors when the sheets are to be imported into Access

Below is the Excel controlling Access code . . .

Code:
Set acapp = CreateObject("Access.Application")
dbname1 = databasename
dbname2 = databasename
Set wkbk = ThisWorkbook

acapp.Visible = True

'Open database
acapp.OpenCurrentDatabase (dbname1)
'TotalControl imports all data from Excel to Access
acapp.Run "TotalControl"
acapp.closecurrentdatabase
'Exit access
acapp.Quit

Set acapp = Nothing

and here is the code in Access for controlling Excel . . .

Code:
Set xlApp = CreateObject("excel.application")

    xlApp.Visible = True
    xlApp.displayalerts = False
    'Open excel file
    xlApp.workbooks.Open ("filename")
    With xlApp
      'do stuff
    End With
I'm sure this is clear as mud.

(1) Do I not want the creation of the Excel Application in the access code as I already have an excel application running . . .

(2) Is this because the Excel code called by Access is not in the original Excel front-end as well?

Thanks
 
Found the problem

In the access coding I should have been using GetObject rather than CreateObject.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top