![]() ![]() ![]() The following example selects the check box control named M圜heckBox, aligns it with the active cell, and then activates the control. This enables Visual Basic code to gain access to these properties by using the control's name. The properties and methods of the OLEObject object are duplicated on each ActiveX control on a worksheet. Worksheets("sheet1").OLEObjects("ListBox1").Delete The following example deletes the OLE object named ListBox1. Worksheets("sheet1").OLEObjects(1).Delete The following example deletes OLE object one on Sheet1. Use OLEObjects ( index), where index is the name or number of the object, to return an OLEObject object. The OLEObjects collection contains all the OLE objects on a single worksheet. The OLEObject object is a member of the OLEObjects collection. Or you can adapt the Open Excel File function above to create a function to open a Word document from Access VBA.Represents an ActiveX control or a linked or embedded OLE object on a worksheet. "C:\Users\Taryn\Desktop\BusinessDocument.docx" Set WordDoc = CreateObject("Word.Application") The following code will allow you to open your Word document using Access: Dim WordDoc As Object ![]() Note: You would do this in the VBE by going to Tools>References and ticking Microsoft Word 15.0 Object Library. ![]() Set myWorkbook = (strFilePath)Ĭall OpenExcelFile("C:\Users\StevePC2\Downloads\test.xlsx")Įnd Sub Open Word Document Using Access VBAįirst set a reference to the Word Library for the Access VBA Environment. Set appExcel = CreateObject("Excel.Application") 'Required: Tools > Refences: Add reference to Microsoft Excel Object Library Public Function OpenExcelFile(strFilePath As String) As Boolean This function below will open an Excel file with Access VBA.īefore using the function, make sure to add a reference to Microsoft Excel Object Library by going to Tools > References and checking Microsoft Excel Object Library. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |