on the machine where the code is running. the machine where the code is running. ![CompanyName] ![ContactName] ![CustomerID] ![Region] """" "Access.Application") "Address," "Arial" "Automation "C:\My "City," "Couldn't "Error: "Excel.Application") "Excel.Sheet "First" "First," "First." "Greeting," "IPM.Contact "Last" "Last," "LastName." "Photo" "Photo": "Please "PostalCode," "Region," "This "User32" "c:\program "special" ' Close the document without saving changes. ' Copy the Photo control on the Employees form. ' Create new hidden instance of Word. ' If a field on the form is empty ' If the Photo field is empty. ' Make the application visible. ' Move to each bookmark and insert text from the form. ' Open the document. ' Paste the photo. ' Print the document in the foreground so Word ' Quit Microsoft Word and release the object variable. ' add this line to reapply the bookmark name to the selection ' close Excel and destroy object variables ' destroy the object ' do something important... ' puts 1000 in cells A1 through C3 of Sheet1 in Book1.xls ' remove the bookmark text and continue. ' set reference to Application object ' set reference to Workbook object ' set the reference to Worksheet object ' unhide the ' will not close until the document finishes printing. 'Check to see if the file name passed in to 'Close 'Macro recorded on 12/20/98 by John Smith 'MyMacro Macro 'New' 'Other Automation code here 'Save the Workbook and Quit Excel 'Show 'the procedure is valid ("c:\my (ByVal (COM), (CStr(Forms!Employees!Address)) (CStr(Forms!Employees!City)) (CStr(Forms!Employees!FirstName)) (CStr(Forms!Employees!LastName)) (CStr(Forms!Employees!PostalCode)) (CStr(Forms!Employees!Region)) (faster). (formerly (slower). (without ---each .Active .ActiveDocument.Bookmarks("Address").Select .ActiveDocument.Bookmarks("City").Select .ActiveDocument.Bookmarks("First").Select .ActiveDocument.Bookmarks("Greeting").Select .ActiveDocument.Bookmarks("Last").Select .ActiveDocument.Bookmarks("Photo").Select .ActiveDocument.Bookmarks("PostalCode").Select .ActiveDocument.Bookmarks("Region").Select .ActiveDocument.Bookmarks.Add Name:="Last",Range:=Selection.Range .Cells.SpecialCells(xlCellTypeFormulas).Select .Close .Documents.Open ("c:\my documents\mymerge.doc") .Font. .InsertParagraphAfter .Legend.Font. .OutputTo acOutputReport, strReportName, _ .Quit .Save .Selection. .Selection.Paste .Selection.Text = (CStr(Forms!Employees!Address)) .Selection.Text = (CStr(Forms!Employees!City)) .Selection.Text = (CStr(Forms!Employees!FirstName)) .Selection.Text = (CStr(Forms!Employees!LastName)) .Selection.Text = (CStr(Forms!Employees!PostalCode)) .Selection.Text = (CStr(Forms!Employees!Region)) .SeriesCollection .Visible = True 1).Value 10. 1000 12/20/98 2000 2000. 3).Value 5.0, 9.0 A property is a characteristic of an object (an adjective). For example, properties of a textbox include: ABC ADO APP_PATH Access Access, Access. Access." Access.Application Access.C Active ActiveSheet ActiveX ActiveX Controls Adding Amber An action that you can take on an object (a verb). For example, a method of an Access form is Angeles" Any item that can be programmed, manipulated or controlled. For example, objects include a textbox, combo box, command button, Word document and more. Microsoft Office 2000 applications include over 500 objects. Attachment. Attempt Attempting Automation Automation (formerly known as OLE Automation) is a feature of the Component Object Model (COM), an industry-standard technology that applications use to expose their objects, methods, and properties to development tools, macro languages, and other applic Automation Client Automation Client = Access Automation Server Automation Server = Word Automation) Automation, Automation. Automation? Axis Background:=False Basic Basic, Basic. Binder Binder. Binding Binding, Binding: Blank Book1.xls Boolean Border Browser Browser. Button: C:\My C:\Program CHM Cannot Caption: Send to Word Case Else Chr(34) Click Microsoft Word 9.0 Object Library in the Available References box. If that selection does not appear, browse for Msword9.olb, which installs by default in the C:\Program Files\Microsoft Office\Office folder. Click OK. Click the Send To Word button to start Microsoft Word, merge data from the current record on the form into MyMerge.doc, print the document, and then close Microsoft Word. Client Client" Client = Access Close Close the module. CloseExcel() Color Column Command Button: Component Components Contact Container." Controls Converter Copy CopyFromRecordset Country Create CreateObject CreateObject("Access.Application") CreateObject("Access.Application.9") CreateObject("Excel.Application") CreateObject("Excel.Sheet") CreateObject("Outlook.Application") CreateObject("Word.Application") Creating a Microsoft Word Document DAO.Database DAO.Recordset Data Database DateAdd("n", DeleteDocsFromBinder_E Depending DestroyIt() Destroying Destroying an Instance of Microsoft Excel Differences Dim ExcelRunning As Boolean Dim SeriesCount As Integer Dim acApp As Access.Application Dim accessApp As Access.Application Dim bindApp As OfficeBinder.Binder Dim db As DAO.Database Dim objAccess As Access.Application Dim olook Dim olookApp As Outlook.Application Dim olookFolder As Outlook.MAPIFolder Dim olookSpace As Outlook.NameSpace Dim rst As DAO.Recordset Dim wordApp As Word.Application Dim wordDoc As Word.Document Dim wordRange As Word.Range Dim xl Dim xlApp As Excel.Application Dim xlApp as Object Dim xlBook As Excel.Workbook Dim xlBook As Object Dim xlSheet As Excel.Worksheet Dir(Path) DoCmd.GoToControl "Photo" DoCmd.RunCommand acCmdCopy DocumentType:=0 Documents Documents. Documents\Book1.xls") Documents\MyMerge.doc, Documents\WordTest.doc, Documents\test.xls" Dynamic ERR_APP_NOTFOUND ERR_FILE_EXISTS Earlier Early Early Binding Easily Edit Editing Editor. Else ElseIf Err.Number = 2046 Then Embedded Employees End Function End If End Select End Sub End With Err.Clear Err.Description Err.Number Error Error.Description Error.Number Even Example Examples Excel Excel, Excel. Excel.Application Excel.Sheet Excel.Workbook Excel.Worksheet ExcelRunning ExcelRunning = IsExcelRunning() ExcelVersion ExcelVersion = Val(xlApp.Application.Version) Exchange Exit Sub Explicit False False, File FileFormat:=xlWorkbookNormal Filename:="E:\Test\TestFile.XLS", Files\Microsoft Folder For SeriesCount = 1 To .SeriesCollection.Count ForeColor Forms.T Formulas Frame Function GetObject GetObject("C:\My GetObject(, GetObject(dbpath) GoTo Graph Graph's GraphObj GraphObj.HasLegend Graphic Graphics HTML HasLegend However, Identifier Identifiers If Dir(Path) = "" Then If Err.Number = 94 Then If Not ExcelRunning Then xlApp.Quit Immediate Import Importance In order to understand automation, it is necessary to understand some basic concepts and terminology: In the Bookmark Name box, type "First," (without the quotation marks) and then click Add. Inbox Insert Installed Installed. Integer IsExcelRunning() IsIconic(hWnd) Keyword Knowledgebase Late Late Binding Legend Library. Long Long) MSGraph.Application MSGraph.Chart Macro Main() Management Mark Marker's MarkerStyle MergeButton MergeButton_Click() MergeButton_Err MergeButton_Err: Messages Method Microsoft Microsoft Access Microsoft Excel Microsoft Graph Microsoft Office Web Components Microsoft Outlook Microsoft PowerPoint Microsoft Word Model Move MsgBox "Error: " & Error.Number & " " & Error.Description MsgBox "File already exists." MsgBox "Please add a photo to this record and try again." MsgBox Err.Number & vbCr & Err.Description MsgBox Path & " isn't a valid path!" MsgBox TypeName(xlApp) Msword9.olb, MyMacro() MyMerge.doc, NEWFILE NOT Name, Visible, ForeColor Name: MergeButton Name:="City") Name:="Last",Range:=Selection.Range NewCurrentDatabase NewTemplate:= Next Northwind Traders Northwind Traders would like to thank you for your employment during the past year. Below you will find your photo. If this is not your most current picture, please let us know. Northwind.mdb. Note Notes Nothing Nothing. OK. OLE OLEFill OWC.Chart OWC.DataSourceControl OWC.ExpandControl OWC.PivotTable OWC.RecordNavigationControl OWC.Spreadsheet Object Object Method Object Property Office OfficeBinder.Binder Office\Office Office\Office\Samples\Northwind.mdb") On Error GoTo MergeButton_Err On Error Resume Next On the Insert menu, click Bookmark On the Tools menu, click References. OnClick OnClick: [Event Procedure] Open any module in Design view. Open the Employees form in Design view. OpenCurrentDatabase OpenXLWorkBook(Path Opening a Microsoft Excel Workbook Option Explicit Orders Outlook Outlook. Outlook.Application Outlook.MAPIFolder Outlook.NameSpace Output PROJECTFILE Parent Paste PathName Photo Populating PostalCode  PowerPoint PowerPoint.Application PowerPoint.Presentation Pre-Existing Presentation Print Private Sub MergeButton_Click() Procedure] ProcessFile() Professional Profile Programmatic Project Property Public Quickly Reading Recommended Recording References References. Referencing Referencing a New Instance of Microsoft Access Referencing an Existing Instance of Microsoft Access Region, Repeat steps 2a through 2c for each of the remaining words, substituting that word for the word "First" in steps 2a and 2c. Resume Resume Next SW_MAXIMIZE SW_SHOW Sample Save the Employees form and open it in Form view. Save the document as C:\My Documents\MyMerge.doc, and then quit Microsoft Word. SaveChanges:=wdDoNotSaveChanges Schedule Secured Select Case Err.Number Select the word "First." Selecting Selection. Send Sending Sending Data to Microsoft Word from a Microsoft Access Form Sending the Current Record to Word. SeriesCount Server Servers, Server = Word Session Sessions Set Set a reference to the Microsoft Word 9.0 Object Library. To do so, follow these steps: Set acApp = Nothing Set accessApp = CreateObject("Access.Application") Set accessApp = Nothing Set bindApp = New OfficeBinder.Binder Set bindApp = Nothing Set db = Nothing Set objAccess = CreateObject("Access.Application") Set olook Set olookApp = CreateObject("Outlook.Application") Set olookApp = Nothing Set olookFolder = Nothing Set olookSpace = Nothing Set olookSpace = olookApp.GetNameSpace("MAPI") Set word Set wordApp = CreateObject("Word.Application") Set wordApp = New Word.Application Set wordApp = Nothing Set wordDoc = Nothing Set wordDoc = wordApp.ActiveDocument Set wordRange = wordDoc.Goto(What:=wdGoToBookmark, Name:="City") Set xlApp = CreateObject("Excel.Application") Set xlApp = CreateObject("Excel.Sheet") Set xlApp = GetObject(, "Excel.Application") Set xlApp = Nothing Set xlBook = Nothing Set xlBook = xlApp.Workbooks.Add Set xlBook = xlApp.Workbooks.Open(Filename:="E:\Test\TestFile.CSV") Set xlBook = xlApp.Workbooks.Open(filename:="c:\My Documents\Book1.xls") Set xlSelection = xlSheet.Cells(rowCounter, 1) Set xlSheet = Nothing Set xlSheet = xlBook.ActiveSheet Set xlSheet = xlBook.WorkSheet(1) Set xlSheet = xlBook.Worksheets(1) SetForegroundWindow Setting the object type to the object variable. Setup, Shape Sheet1 Shell ShowAccess ShowWindow ShowWindow(hWnd, Slide Smooth Snapshot Solutions SpecialCells Specification. Start Microsoft Access and open the sample database Northwind.mdb. StartAccess() Stop String String) String, Sub Sub CloseExcel() Sub DestroyIt() Sub Main() Sub MyMacro() Sub OpenXLWorkBook(Path As String) Sub ProcessFile() Sub StartAccess() Sub usingRange() Subject, Suppliers Table Tasks Template:="", Terminating Test." Text:="This Texture The "Automation Client" is the application that decides which objects to use and when to use them. The "Automation Client" is also referred to as "Automation Container." For example, if a button is clicked on an Access form, and a letter prints in Word: The Automation Server is the application that exposes the automation object(s). The following example uses bookmarks in a Microsoft Word document to mark the locations where you want to place data from a record on a Microsoft Access form. Therefore, These This document was generated by Trial version of ABC Amber CHM Converter program Thus, To create this object Tools Traders Trial Troubleshooting True True. TypeName(xlApp) Under Use one of these identifiers UserControl Using Using API calls to Bring Microsoft Access into View Using the Range Object With Microsoft Excel Val(xlApp.Application.Version) Variant Variant. Versions Visible, Visual Web Weight What What is Automation? When an application supports Automation, the objects the application exposes can be accessed through Visual Basic. You can use Visual Basic to manipulate the objects by invoking methods or by getting and setting properties of the objects. While Windows With GraphObj With WordDoc With bindApp With rst With wordApp With xlSelection With xlSheet Word, Word. Word.Application Word.Document Word.Range Word 9.0 WorkBook, Workbook Worksheet: WrkBook You You're [Event [Trial version] above acApp acApp.Quit acCmdCopy acOutputReport, accessApp accessed account action activate activates active actually add address adjective). after again." all allow allows already also always analyze and and more. another answers any appAccess appear appear, append applic application application's application, application. applications applications, applies apply approach are argument array article article, aryData(intCount, associated assumes attachments automate automatically automating availabl available because become been before behavior being below. better between bindApp binding. bookmark bookmark, bookmark. bookmarks border, both bottom box box, box. bring brought browse build built-in business button button, call called calling calls can case case, cause cell cell, cells change change. changes changes. changing characteristic chart chart, chart. check checkbox class click clicked clicking clipboard closes closing code code, code. collaboration color, colors columns. command common communicate compile component. computer, concepts consider constants contacts contain containing contains content. contents continue continue. control controlled. controlling correctly corresponding could count create created creates creating creation current currently custom dashed data. database. db.Close dbpath decides declarations declare declares default defined delete deleting demonstrate demonstrated demonstrates described design destroy destroyed detail determine development dialog different direct display displays document document, document. document: documents\mymerge.doc") does doesn't download drop-down during each easier either employment empty. enables enhanced enter entered error. errors establish event events, ever everything example, example. example: existing exists, exists." explicitly expose exposes fMoreThanOne false. faster feature field file, find finishes first folder. follow following follows: for for more information. foreground form form, form. format frames friendly from full function, function. functionality functions functions. generated get getting gives graph, graphed. graphical graphs hWnd handler has have having help here hidden how ideas identifiers. illustrates immediately important important... improve include include: industry-standard information information, information. initialized inserted inserting installs instance instance, instance. instances intCount intSectionCount integration interface into invisible invoking isn't it. its keyword known languages, launch legend's legend. letter libraries library library, like line line, lines linestyle list listed lngRptType located location locations loop loses machine macro mail make makes making manage manipulate manipulated manipulating manually, marks) may menu, message message. messaging method, method. methods methods, might minimized minutes model. modify module module. module: more more. most msoBringToFront multiple must name named necessarily necessary need new normal number objAccess objAccess, objApp objProject objWord objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges objWord.ActiveDocument.PrintOut Background:=False objWord.Selection.Text = "" object's object(s). object) object, object. objects objects, objects. occurs occurs when you declare object variables with a specific class and the binding occurs when the code runs (slower). occurs when you declare object variables with a specific class and the binding occurs when you compile the code (faster). offers office\office\samples\northwind.mdb" olText) olookApp olookApp.GetNameSpace("MAPI") olookAttach olookContact olookFolder olookInbox olookMsg olookNote olookRecipient olookRecipient.Resolve olookSpace olookTask olookUserProp omit one one. only open open. opened opening opens opgRptType optional order organize other outline over paragraph paragraph, particular pass passed path path!" performance photo. picture, place please point points position possible possible, powerful ppApp ppCurrentSlide ppPres ppShape pre-defined prevent preview previous printing. prints problem problems procedure procedure, procedure. procedure: processor productivity program programmed, programmers prompting properties properties, properties: property, provides quit quotation range rangeItem rather reapply recent recipient(s) record recorded records recordset refer reference referred refers regardless region release remaining remove report represents requests require requires resolve result results retrieve return returned returns rowCounter rowCounter = rowCounter + 1 rst run run-time running running. sNWind save savechanges:=True saved saving scope scope, scope. search second section see select selected selection sentence. series session. sets setting setting. shapes share sheet should show shown since size solutions, some something sometimes special specific specified specified, specify specifying spreadsheet spreadsheets start started starting steps steps: strNotFound strReportName, strReportPath strUser streamlined substituting such suffix, support supports sure syntax system table, table. take task technology temp terminate terminated terminates terminology: test text textbox textbox, than that the their then there this this, through time tions. For example, a spreadsheet application might expose a worksheet, chart, cell, or range of cells ---each as a different type of object. A word processor might expose objects such as an application, document, paragraph, bookmark, or sentence. toggle toolbar tools, topic transfer transferring trappable true, two type unbound understand unhide unless until use use. used useful user user's user, user. uses usingRange() usually valid value values varTemp varTemp = xlSelection.Value variable variable, variable. variables various vbCrLf verb). version version] view view, view. viewer visible visible. want was well when where whether which whose will window window. wish with within without word wordApp wordApp.ActiveDocument wordApp.Quit wordApp.Visible = True wordDoc wordDoc.Goto(What:=wdGoToBookmark, wordPara wordRange wordRange.InsertAfter "Los Angeles" wordRng words words, work workbook's workbook. workbooks working works worksheet worksheet, worksheet. would writing xlApp xlApp. xlApp.ActiveCell.Value = 10 xlApp.Quit xlApp.Sheets(1).Cells(1.1).Select xlApp.Visible = True xlApp.Workbooks.Add xlApp.Workbooks.Open Path xlApp.Workbooks.Open(Filename:="E:\Test\TestFile.CSV") xlApp.Workbooks.Open(filename:="c:\My xlBook xlBook.ActiveSheet xlBook.Close xlBook.Close savechanges:=True xlBook.SaveAs Filename:="E:\Test\TestFile.XLS", FileFormat:=xlWorkbookNormal xlBook.WorkSheet(1) xlBook.Worksheets(1) xlSelection xlSelection. xlSelection.Value xlSheet xlSheet.Cells(3,3)).Value xlSheet.Cells(3,3).Value xlSheet.Cells(rowCounter, xlSheet.Range(xlSheet.Cells(1,1), xlSheet.Cells(3,3)).Value = 1000 xlSheet.Range(xlSheet.Cells(1,1), xlSheet.Cells(3,3).Value = 1000 xlWindow you've your