Automate hide / unhide slide in Powerpoint

S

Steve

I am developing a slide show to show charts in our production area. I
am used a spreadsheet to generate the charts and have linked them to a
powerpoint slideshow. There is a total of 150 charts in the slide show.
I want be able to show only the slides with a value. Does anyone know
if you can automate Powerpoint to validate a value in a spreadsheet
(Excel) and based on this value change the properities of a slide to
hide or unhide? The slide show runs for 10 hours a day and it is setup
to look at the spreadsheet at the begining of each loop to update the
charts.

Thanks
 
B

Brian Reilly, MVP

Steve,
Yes you could do this and without much code at all.

First question would be do you want this code to run inside PPT or
inside Excel? Assuming it is in PPT.

Then, create an event for the first slide. see
http://www.rdpslides.com/pptfaq/FAQ00741.htm for that.

Then modify the following code to activate the Excel workbook and
check the cells you want for either IsBlank or IsEmpty or some other
criteria and set the slide to hidden = true or false based on that.

Private Sub cmdExcel_Click()

'Check if an instance of Excel is running. If so obtain a
reference to the running Excel application
'Otherwise Create a new instance of Excel and assign the XL
application reference to oXLApp object
On Error Resume Next
Err.Number = 0
Set oXLApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Err.Number = 0
Set oXLApp = CreateObject("Excel.Application")
If Err.Number <> 0 Then
MsgBox "Unable to start Excel.", vbInformation, "Start
Excel"
Exit Sub
End If
End If

On Error GoTo Err_Handler

'To Make Excel App visible
oXLApp.Visible = True

'To Open a New XL Workbook
If oWb Is Nothing Then
Set oWb = oXLApp.workbooks.Add
End If

'Include necessary code here by preceding oXLApp to refer to the
Excel object
'and oWb to refer to the Excel Workbook object

Exit Sub

Err_Handler:
MsgBox Err.Description, vbInformation, "Start Excel"
End Sub

This code was written by Naresh Nichani, an Access MVP to demonstrate
how to control other Office applications from PowerPoint. Steve
Rindsberg will probably post the entire set of code on the PPTFAQ,
shortly after I send it to him.

Brian Reilly, MVP
 
S

Steve

Yes, I would prefer to run it in Powerpoint. So I understand this
correctly (limited programming experience). Here is what I have so far.

Excel Spreadsheet: production.xls
Worksheet 1 = Name: AB Type: Data Input Screen
Worksheet 2 = Name: BC Type: Data Input Screen
Worksheet 3 = Name: CD Type: Data Input Screen
Worksheet 4 = Name: Chart1 Type: Chart linked to AB PowerPoint Slide:
1
Worksheet 5 = Name: Chart2 Type: Chart linked to AB PowerPoint Slide:
2
Worksheet 6 = Name: Chart3 Type: Chart linked to BC PowerPoint Slide:
3
Worksheet 7 = Name: Chart4 Type: Chart linked to BC PowerPoint Slide:
4
Worksheet 8 = Name: Chart5 Type: Chart linked to CD PowerPoint Slide:
5
Worksheet 9 = Name: Chart6 Type: Chart linked to CD PowerPoint Slide:
6
Etc.

I want to reference a cell for a value in worksheet AB.
If the value A1="T" than change the properties of slide 1 & 2 to
unhide.
If the value A1=0 than change the properties of slide 1 & 2 to hide.

I want to reference a cell for a value in worksheet BC.
If the value A1="T" than change the properties of slide 1 & 2 to
unhide.
If the value A1=0 than change the properties of slide 1 & 2 to hide.

I want to reference a cell for a value in worksheet CD.
If the value A1="T" than change the properties of slide 1 & 2 to
unhide.
If the value A1=0 than change the properties of slide 1 & 2 to hide.

Can you assist me with the proper code?
 
S

Steve

Correction:


I want to reference a cell for a value in worksheet AB.
If the value A1="T" than change the properties of slide 1 & 2 to
unhide.
If the value A1=0 than change the properties of slide 1 & 2 to hide.

I want to reference a cell for a value in worksheet BC.
If the value A1="T" than change the properties of slide 3 & 4 to
unhide.
If the value A1=0 than change the properties of slide 3 & 4 to hide.

I want to reference a cell for a value in worksheet CD.
If the value A1="T" than change the properties of slide 5 & 6 to
unhide.
If the value A1=0 than change the properties of slide 5 & 6 to hide.
 

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