# Powerpoint VBA: Open Excel On click



## Mike Blackman (Mar 19, 2009)

Hi All,

I have a couple of questions about using VBA within Powerpoint;


I want to call an already opened Excel Spreadsheet by clicking on an image
I want to open another Excel Spreadsheet via clicking on an image: I obviously know how to do this from within the VBE in excel but don't know how I get to give excel orders from within Powerpoint

I know how to assign macro's by clicking on images within Powerpoint BTW.

Any help/advice is appreciated.


----------



## Mike Blackman (Mar 19, 2009)

OK,

So i'm getting there, I just need to be able to close the userform named CustomerName but it just isn't having it.


```
Sub OpenSLAReport()

With Excel.Application
    .Visible = True
    .Workbooks.Open FileName:="C:\Documents and Settings\michael.blackman\My Documents\SLA Template" _
        & "\Models\v5.2\MPLS SLA Report Template v5.2.xls"
    CustomerName.Hide
End With

End Sub
```

Please help.


----------



## Richard Schollar (Mar 19, 2009)

Mikey

Is it just 


```
Unload CustomerName
```
 
I take it it is a userform in Powerpoint rather than the opened session of Excel?


----------



## Mike Blackman (Mar 19, 2009)

Hi Richard,

No its actually a UserForm from the opened Excel model; I tried;


```
Unload CustomerName
```

and


```
Unload .CustomerName
```

and I just can't get it to speak to Excel, i also tried; 


```
.ActiveWorkbook.CustomerName.Hide = True
```

Nothing I can think of will shift it.


----------



## Richard Schollar (Mar 19, 2009)

Do you actually need this userform in Excel?  If not you could presumably tell the xlApp not to activate any event code macros.


----------



## Mike Blackman (Mar 19, 2009)

Hi Rich,

The userform is triggered on Workbook open as I'm sure you've assumed, I will however need all my events in place as I will be demonstrating how my workbook functions and how to use it. I guess the question is, Can I dsable events within my PP code which will stop the On_Open event triggering but enable at the end of the code after the workbook has opened? Does that make sense?

I assume the code would be;


```
Sub OpenSLAReport()

With Excel.Application
    .Visible = True
    .EnableEvents = False
    .Workbooks.Open FileName:="C:\Documents and Settings\michael.blackman\My Documents\SLA Template" _
        & "\Models\v5.2\MPLS SLA Report Template v5.2.xls"
    .EnableEvents = True
End With

End Sub
```


----------



## Richard Schollar (Mar 19, 2009)

Looks good to me, but I've never used it when automating Excel before...


----------



## Mike Blackman (Mar 19, 2009)

Fair Enough, wasn't sure if the syntax was theoretically correct, assumed it was;


```
Excel.Application.EnableEvents = FALSE
```

It works at least.

Cheers Rich.


----------

