Openning embedded Excel workbook

M

Miguel Velez

I got a Ms Word document with an embedded Ms Excel
workbook. I've written some VBA code to open the workbook
but when it runs a dialog comes up warning me that the
workbook contains macros and whether I want them enabled.
Since the next thing the code does is run the macro
contained by the embedded workbook, the answer is "Yes".

The code looks like this:
Dim xl As Object

With ActiveDocument.Shapes("Object 42").OLEFormat
.Activate
Set xl = .Object
End With
xl.UpdateChartFromPEST
Set xl = Nothing


I've tried adding this line after the ".Activate" line:
SendKeys "%y"
but it doesn't work. Does anyone know how I can select
from code the "Yes" button in the dialog?

Thanks in advance.

Miguel
 
P

Perry

Please do not send duplicate questions.

Here's an answer between <q> and <unq>

<q>
In Excel, adjust the Security setting as follows:

Tools | Macros | Security
In security dialog tab: Trusted Publishers
Check the checkbox: Trust Access to Visual Basic project.

See whether this helps.

Krgrds,
Perry
<unq>
 
M

Miguel Velez

Perry,

It wasn't my intentioned to post duplicate questions. I
posted the first one and when I came back some time later,
it wasn't listed. So I thought I hadn't posted it properly.

Miguel
 

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