How to reference an embedded PowerPoint or Excel f

2019-06-23 18:57发布

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条回答
三岁会撩人
2楼-- · 2019-06-23 19:24

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.

查看更多
登录 后发表回答