Open excel spreadsheet from within Access using VBA 
Author Message
 Open excel spreadsheet from within Access using VBA

Can I activate an Excel workbook from within Access without embedding the Excel
workbook in an Access form ? Any help would be appreciated.

Chad



Fri, 19 Apr 2002 03:00:00 GMT  
 Open excel spreadsheet from within Access using VBA


Quote:
> Can I activate an Excel workbook from within Access without embedding
the Excel
> workbook in an Access form ? Any help would be appreciated.

> Chad

Absosmurfly! Standard OLE Automation
If you look in the Access 97 help under GetObject, it has an example
(paraphrased below):
Sub GetExcel()
        Dim MyXL As Object      ' Variable to hold reference
        ' to Microsoft Excel.

        On Error Resume Next
        Set MyXL = Getobject(, "Excel.Application")
        Err.Clear       ' Clear Err object in case error occurred.

        'Set the object variable to reference the file you want to see.
        ' NOTE: Make sure the file exists
        Set MyXL = Getobject("c:\vb4\MYTEST.XLS")

' Show Microsoft Excel through its Application property. Then
' show the actual window containing the file using the Windows
' collection of the MyXL object reference.
        MyXL.Application.Visible = True
        MyXL.Parent.Windows(1).Visible = True

' Do manipulations of your
        ' file here.
        ' ...
        MyXL.Application.Quit

        Set MyXL = Nothing ' Release ref to the app and spreadsheet.
End Sub

NOTE: The Excel.Application parameter is a subfolder of
HKEY_CLASSES_ROOT folder in the Registry. See the other analogous items
in HKEY_CLASSES_ROOT to do the same type of manipulations with other
types of files/applications.

RV
--
We come from the land of the ice and snow
Where the midnight sun and the hot springs blow
The hammer of the gods will drive our ships to new lands
To fight the hordes, singing and crying, 'Valhalla, I am coming....'

Sent via Deja.com http://www.deja.com/
Before you buy.



Sat, 27 Apr 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using DDE to open an Excel Spreadsheet

2. VBA, Excel spreadsheet to Access Database

3. Creating excel Spreadsheet from Access VBA

4. Prompts to update links when opening Excel spreadsheet from Access

5. Opening an Excel template from within Word VBA

6. Opening an Excel template from within Word VBA

7. linking an excel spreadsheet to an access database using vb

8. Excel spreadsheet from an Access database using VB?

9. Accessing an Excel spreadsheet using ASP

10. Importing Excel Spreadsheet into an Access 2000 Table using VB

11. linking an excel spreadsheet to an access table using vb

12. how to delete a macro within an Excel document by using VBA

 

 
Powered by phpBB® Forum Software