Excel from Access form

D

Darejamr

How do I dispaly a specific excel eorksheet in an excel workbook from an
access form. I have been able to display the specific workbook using the
SHELL comand but can't figure out how to display a specific woorksheet in the
workbook.
 
A

Arvin Meyer [MVP]

This will import to a specific table from a specific worksheet:

http://www.mvps.org/access/general/gen0008.htm

Here's a way using automation and early binding (you'll need to set a
reference to Excel):

Sub SampleExcelCode()
On Error GoTo Error_Handler

Dim appXL As Excel.Application
Dim wkb As Excel.Workbook
Dim wks As Excel.Worksheet

Set appXL = New Excel.Application
Set wkb = appXL.Workbooks.Open("C:\FolderName\ExcelFile.xls")
Set wks = wkb.Worksheets(1) ' This opens the first worksheet
appXL.Visible = True
' ... Do something
Exit_Here:
wkb.Close xlDoNotSaveChanges
Set wkb = Nothing
Set appXL = Nothing
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub

Error_Handler:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Here

End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
J

Joerg Ackermann

Darejamr said:
How do I dispaly a specific excel eorksheet in an excel workbook from
an access form. I have been able to display the specific workbook
using the SHELL comand but can't figure out how to display a specific
woorksheet in the workbook.


Application.FollowHyperlink "file://f:\excelfiles\test.xls", "Worksheet2!A1"

Acki
 
L

Lee Li

you have to import excel worksheet to access so that you able to view in
access form.
 
A

Arvin Meyer [MVP]

Actually, you can link an Excel Spreadsheet, exactly like you would an
Access table. The biggest drawbask to this is the fact that only one person
can work on a spreadsheet at a time, similar to locking an entire table in
Access.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Top