How to reference an embedded PowerPoint or Excel file in a form in Access?

北城以北 提交于 2019-12-10 15:45:45

问题


So if I was to take a an Access form, and embed either an Excel spreadsheet into it or a PowerPoint deck, how would I reference it in VBA code?

I know I have to set the libraries, name the frame of the OLE object, and use applicable syntax to whatever I want to do, with whatever I stick in the form, however the only things I have ever done with Excel and/or PowerPoint is automate the opening of a seperate window/application from Access, not within the Access form. So I am not sure how to proceed.

If I said its a new Excel.Application, then set xls = to (the ss in the file, and not some file path of another Excel file somewhere)?

Does that make sense?


回答1:


Let's say you added an Excel Workbook Object in your Form, named it xLObject and added a Reference to the Excel Object Library in VBA

Here is how you Access a Sheet of this Object and change a Range

Dim sheet As Excel.Worksheet
Set sheet = xlObject.Object.Sheets(1)
sheet.Range("A1") = "Hello World"

The same logic applies to Powerpoint.



来源:https://stackoverflow.com/questions/2588009/how-to-reference-an-embedded-powerpoint-or-excel-file-in-a-form-in-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!