
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.