whats is this

C

Cecilia Reyes

i was reading the board to find out how to import a file
from excel to access and i foud this.

A sample Sub to demonstrate Excel Automation.

'************ Code Start **********
'This code was originally written by Dev Ashish
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code Courtesy of
'Dev Ashish
'
Sub sTestXL()
Dim objXL As Object
Dim strWhat As String, boolXL As Boolean
Dim objActiveWkb As Object

If fIsAppRunning("Excel") Then
Set objXL = GetObject(, "Excel.Application")
boolXL = False
Else
Set objXL = CreateObject("Excel.Application")
boolXL = True
End If

objXL.Application.workbooks.Add
Set objActiveWkb = objXL.Application.ActiveWorkBook

With objActiveWkb
.Worksheets(1).Cells(1, 1) = "Hello World"
strWhat = .Worksheets(1).Cells(1, 1).value
End With

objActiveWkb.Close savechanges:=False

If boolXL Then objXL.Application.Quit

Set objActiveWkb = Nothing: Set objXL = Nothing
MsgBox strWhat
End Sub
'************ Code End **********



what is AUTOMATION?
what does the code do?
 
I

Immanuel Sibero

Hi

Automation is programmatically executing, controlling one application from
another. For example, the code you found is program in Access to execute and
controlling Excel. The code is an example to open up Excel, add a sheet and
prints Hello World in cel A1.

HTH,
Immanuel Sibero
 
C

Cheryl Fischer

Automation is a way to work with an application's objects from another
application or development tool. Formerly called OLE Automation, Automation
is an industry standard and a feature of the Component Object Model (COM).).
That is from VBA Help on Automation.

A more practical definition is: Automation is a way to open a program such
as Word, Excel, Outlook, etc. and use the program's own VBA language to
create new Word documents, open existing Word documents, send data to Word
templates, create new spreadsheets or send data to existing spreadsheets in
Excel, create and send Outlook emails, appointments and tasks, add or update
Outlook contacts -- all from within an Access database.

Typically, you would use Automation to send data in a database to one of
these objects; for example, Name and Address lines from a database to a
series of form letters in word or Outlook email confirmation of an order
that has been added to the database, etc. Not all programs make their
objects, properties and methods available for Automation. Outlook Express
is an example of a Microsoft product that does not.

The code you found first determines whether an instance of Excel is open.
If it is, the code activates the current instance of Excel and makes it
visible to Access; if not, Access opens an instance of Excel. It then makes
a new workbook the active object - which Access will work on. Last, it
writes "Hello, world" into Row 1, Column A of Sheet 1.

hth,
 
C

Cecilia Reyes

So that means i can open an excelbook, use a form that i
created in that excellbook (to modify the excell sheet)
and then i can import the modified sheet ?
HOW!!!!?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top