Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a Catalog

Status
Not open for further replies.

Rseven

Technical User
Mar 7, 2006
41
US
Good Morning,Was looking for some assistance with some VBA code to create a catalogue of items in a PowerPoint report. For example I have a list of customer numbers that I want to lookup in the report and list the page # they are on for quick reference. Please see attachment

Thank you in advance
 
 http://files.engineering.com/getfile.aspx?folder=b283ea1d-4886-45f4-8a2c-705236955529&file=Presentation1.pptx
Hi,

Why are you trying to use a hammer as a screwdriver?

PowerPoint is a PRESENTATION application.

To manipulate and report from tables, you might want to condider Access or Excel.
 
list of customer numbers that I want to lookup in the report and list the page #

This is commonly called an INDEX. MS Word can do this easily- no VBA required.
 
I agree completely with Skip. If you are presenting these in PowerPoint, you must be getting them from somewhere else first - especially as they seem to be locked in an image - so go back to the source.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Thanks for the feedback. Unfortunately due to privacy I had to remove some of the data and paste it as an image. In the real presentation, the objects are not locked down. The report is sourced through MS Excel and there is VBA in Access that copies and pastes the information into a PowerPoint presentation. I would then like the code to do a "lookup" in PP and put the page # in the right hand column. If it is not possible, it is ok, but would like to automate that along with maybe a hyperlink to the page, if possible.

Again, thanks in advance and for the quick responses
 
The IMAGE has absolutely NOTHING to do with the logic of my argument.

I'm considering the tool. It's a PRESENTATION tool that is not designed for this purpose. So far your persistence in using this tool inappropriately has not been supported by any sufficient reason to justify Power Point as the proper tool.

I've been known to use a knife as a screwdriver, when no screwdriver is available. But I would not at all recommend that kind of abuse.
 
I am interpreting this different than Skip.
1) You are exporting some date from Excel or Access into a series of PPT slides
2) Certain "Records" will end up on certain slides
3) Once you populate the PPT, you would like to create a "Index" at the beginning of the PPT
that lists all the issues exported to the PPT and which slides they end up

Seems logical to me. I think the term catalog was confusing. If my assumption is correct, this should be doable.
 
Why?

You are getting information from Excel or Access. So presumably you know what the information is.

You are placing the information into PowerPoint. So you have control over, and know where it is placed.

Build your index from that.

No need to go through the extra effort of finding it again.
 
I'm not saying it can't be done.

I'm challenging the OP to justify the use of this tool as opposed to one more suitable.

He references a customer number to a page of a report somewhere else.

How about a dropdown of customer numbers, that when you select one, you immediately see what is reported for that customer? All that can easily be done in Excel, for instance. Best if you know where the report came from--its data source.
 
As mentioned ideally as you export from Access and create your slides, you should be building your Table of Contents/Index at the same time. Create a slide then add it to the TOC/Index. You would not want to search for items after the fact. But if for some reason you cannot then, you will still somehow need to get from Access the list of items to search for. That could be done after the fact. So my function GetIssues in this example may be an ado connection back to the source and you would return and loop the recordset of issues. In your creation of the PPT, you may also be creating that list, so I guess you could loop that list.

Anyways here is a primitive example to get you started. I am not a PPT developer so it is pretty primitive. It loops the issues and creates a new slide with the issue hyperlinked to the page. For some reason the hyperlink exists, but is not clickable. I took some of the code from an example where they built a TOC taking the title of each slide as the items for the TOC.

Again I interpret this to be a simple reporting application. All reall management and analysis is done in Excel or Access.

Code:
Sub Build_Index()
Dim Mstr As CustomLayout
Dim SlidePosition As Integer
Dim Activeslide As PowerPoint.Slide
Dim TOCSlide As PowerPoint.Slide
Dim I As Integer
Dim Issues As Collection
Dim Issue As String
Dim FoundSlide As PowerPoint.Slide
Dim bodyText As PowerPoint.TextFrame
Dim sldID As Long
Dim sldindx As Long
Dim hypStart As Long
'assign custom objects
Set Mstr = ActivePresentation.Designs(1).SlideMaster.CustomLayouts(2)
Set Activeslide = Application.ActiveWindow.View.Slide

' determine required inputs
SlidePosition = Activeslide.SlideIndex

'insert slide to hold TOC at current location
Set TOCSlide = ActivePresentation.Slides.AddSlide(SlidePosition, Mstr)
TOCSlide.Shapes.Title.TextFrame.TextRange = "Index"
Set bodyText = TOCSlide.Shapes.Placeholders(2).TextFrame

'loop through each slide compiling TOC from slide titles
Set Issues = GetIssues
I = 1
For I = I To Issues.Count
  Issue = Issues(I)
  Debug.Print Issue
  Set FoundSlide = FindSlide(Issue)
  ' add Issue to page as text
  bodyText.TextRange.InsertAfter (Issue & " " & Chr(13))
 ' create a hyperlink entry for TOC rather than a simple text entry
 ' get the information required for the hyperlink
 sldID = FoundSlide.SlideID
 sldindx = FoundSlide.SlideIndex
 ' find the text string in the body
 hypStart = InStr(1, bodyText.TextRange.Text, Issue, 1)
 'make the text a hyperlink
 With bodyText.TextRange.Characters(hypStart, Len(Issue)).ActionSettings(ppMouseClick).Hyperlink
        .SubAddress = FoundSlide.slideNumber
 End With
 Debug.Print sldID & "," & sldindx & "," & Issue
Next I


'release object
Set Mstr = Nothing
Set Activeslide = Nothing
Set TOCSlide = Nothing
Set bodyText = Nothing
End Sub

Public Function GetIssues() As Collection
  Dim Issues As New Collection
  Issues.Add ("IS 485")
  Issues.Add ("IS 486")
  Issues.Add ("AR 650")
  Set GetIssues = Issues
End Function

Public Function FindSlide(StrText As String) As PowerPoint.Slide
    Dim sld As PowerPoint.Slide
    Dim shp As PowerPoint.Shape
    Dim txtRng As PowerPoint.TextRange
    Dim rngFound As PowerPoint.TextRange
    Dim I As Long
    Dim n As Long
    On Error GoTo errlbl
    For Each sld In Application.ActivePresentation.Slides
    '~~> Loop through each shape
      For Each shp In sld.Shapes
         '~~> Check if it has text
         If shp.HasTextFrame Then
            Set txtRng = shp.TextFrame.TextRange
            '~~> Find the text
            Set rngFound = txtRng.Find(StrText)
             '~~~> If found
             If Not rngFound Is Nothing Then
                Set FindSlide = sld
                Exit Function
             End If
         End If
        Next
    Next
    Set shp = Nothing
    Set sld = Nothing
    Exit Function
errlbl:
    MsgBox Err.Number & " " & Err.Description
End Function
 
Thanks MajP, I'll give it a try. I appreciate the all the feedback. You hit it on the head. The data is stored in an Access database, then exported to Excel via VBA. From there I have VBA that reads Excel and copies and pastes the items in PPT. Once in PPT I would like to create and "Index" so when presented by management there is quick reference to the page the detail is on.

Just one question; in the Get Issues procedure, do I have to list all the numbers or is there a way it can do a lookup? The numbers will be different every month.

Thanks again for your help
 
Just one question; in the Get Issues procedure, do I have to list all the numbers or is there a way it can do a lookup? The numbers will be different every month
For sure you would not hard code the list, I just do not now what access you have to the source data and code.
Like I said the ideal way to do this is to add to the TOC/Index as you build your slides, so you would never search for anything. As you add IssueXYZ to the slide deck you would simultaneously add it to the TOC/Index. Is that an option? Do you control the code for that? For sure it will be a lot easier to automate from access, then build the slides and run separate code in PPT. But lets assume you have no control of the Access code, can you link back to the access data base from PPT? In that case the PPT file could query the Access database and get the list of issues in your slides. If that is not possible, for example someone provides you the PPT file and you do not control the source data, then you have the final option. If the things you are looking for are in a specific format then you could search that way. I do not know your business processes.
 
As I stated earlier, referring to a PAGE on a REPORT in some OTHER LOCATION is a klunky, unorthodox, silly method of using automation!

Sounds to me like the idea of Dilbert's boss.
 
I have full access and control of the data, code and database.
 
Why is it important to use this report?

Rather than say, go find your data on this page number, why not just display the data they want--the data for the customer?
 
As I stated earlier, referring to a PAGE on a REPORT in some OTHER LOCATION is a klunky, unorthodox, silly method of using automation!
Maybe I am missing something, but this seems pretty common to me. All the OP seems to be doing is creating a report/brief and making a hyperlinked TOC/Index. What is klunky and unorthodox.
To me this is pretty common. Example. We maintain a database of Projects. Quarterly we create PPT quad charts for each project. The database builds each of the quad charts slides (basically the 5Ws for a program, cost, schedule). Then there is a TOC with hyperlinks to each project's slides. Leadership gets the slide deck and can click on the Projects that interest them without scrolling through 10s-100s of slides. Sure, I guess you could probably make a web app to view the quads, but the PPT work fine for distribution and presentation, and the hyperlinks are real handy.
It is also pretty common for a large brief to have a TOC to navigate through the brief for presentation. If I have a large brief with something like system specs, each page of the brief would have a hyperlink back to the TOC, and the TOC would have hyperlinks to each of the pages. Then when I am in front of decisions makers giving a brief I am not spending 5 minutes scrolling through slides, to show them something they want to see. I go to the first slide, and click on the spec/issue/whatever they want to see.
More commonly I do the same thing in a Word document. I might export a thousand requirements into a formatted Word Template, and when all done build a hyperlinked TOC/Index. If you got a 200 page system spec, it is pretty nice to go into the index and click on the one you are looking for.
 
Then there is a TOC with hyperlinks to each project's slides
Which app builds the TOC ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Then there is a TOC with hyperlinks to each project's slides Which app builds the TOC
In my case I am exporting data from Access into PPT, creating formatted PPTs. Access is automating PPT and creating the hyperlinks.

I have full access and control of the data, code and database.
So that is obviously the preferred option. If I understand you are creating your brief/report by Access automation. As Access creates slides, it should update the index/TOC. Create a slide, update the TOC/index. Is each slide a specific customer?
 
The data is stored in an Access database, then exported to Excel via VBA. From there I have VBA that reads Excel and copies and pastes the items in PPT. Once in PPT I would like to create and "Index" so when presented by management there is quick reference to the page the detail is on.
Unless you actually need the data in Excel, exporting from Access to Excel and from there to PowerPoint sounds dumb - and it's inefficient to do it that way even if you do need the data in Excel for some other purpose. Since you already have the data in Access and undoubtedly already know which slides the data populate, why are you not simply populating the slides directly from Access and adding the 'index' details to the first slide as you go? Furthermore, unless this presentation is primarily intended to be displayed via a projector, why are you outputting to PowerPoint at all? Why not use an Access report or a Word mailmerge (to which a TOC could easily be added)?

Cheers
Paul Edstein
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top