Solved

Creating custom ribbon gallery in PowerPoint with VBA - specifying image location

Posted on 2014-09-29
7
566 Views
Last Modified: 2014-10-17
Hi

I am coding a custom gallery which I would like to display all the images in a specific network folder. I have coded the XML fine, but am having trouble with the VBA for the "GetItemImage" element. I have JPGs in my file, but it doesn't seem to be finding the file names, just the folder location.

Please can you tell me where i am going wrong with this. My code is as follows:

Sub PL_image(control As IRibbonControl, Index As Integer, ByRef image)

Dim stpath As String
Dim imgpath As String
Dim imgname As String

stpath = "\\MYPATH\" & imgname 'Path to Picture Library

imgpath = Left(stpath, InStrRev(stpath, ".") - 1)

Set image = LoadPicture(imgpath & ".jpg")

End Sub
0
Comment
Question by:Sim Kuch
  • 3
  • 2
  • 2
7 Comments
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40351522
Stand by.....
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40351545
How do you place the images into the ribbon. Do you just use "Insert" or "Insert and link"?
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 40351559
Forget my last question. I am not very familiar with iRibbonControls.

Here is a reference which MAY HELP IF YOU READ THROUGH THE CODE:
http://gregmaxey.mvps.org/word_tip_pages/dynamic_ribbon_menu.html

The "callbacks" to objects in the ribbon may be able to get what you are after.

At the moment your code has an empty string for " imgname" and a value is never assigned to it.
You must find a way of getting the filename for an image from the ribbons images.
It is a shame you are using "image" rather than "graphic" since graphics has a property "filename").

I better not say too much more since I may be just saying "rubbish", but perhaps the link I have supplied might lead you somewhere.

If I discover anything else I will get back to you. Let me know of any developments.

Cheers

Chris (Melbourne-Australia)
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 23

Expert Comment

by:JSRWilson
ID: 40356399
You need to use a dynamicGallery not a DynamicMenu and you need to post your XML

XML should look something like this

    <gallery id="mygall" label="NEW" imageMso="HappyFace" size="large" onAction="runGall" getItemHeight="getH" getItemWidth="getW"  
     columns="5" rows="4" getItemCount="getCount" getItemImage="getimage" getItemID="getID"  />

GetItemImage does not exist it's getItemImage (case is vital in XML)
0
 

Accepted Solution

by:
Sim Kuch earned 0 total points
ID: 40356489
Thanks for your comment - the xml is working fine - I was using getItemImage, I typed it incorrectly here

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="OnSKload">
  <ribbon startFromScratch="false">
    <tabs>
      <tab id="Custom_tab" label="SharePoint" keytip="Y">
        <group id="SharePoint" label="SharePoint">
          <gallery id="PictureLib"
            columns="4"
             label="Insert image from SharePoint"
            size="large"
            imageMso="ClipArtInsert"
            itemHeight="100"
            itemWidth="100"
            getItemCount="PL_count"
            getItemImage="PL_image"
            onAction="PL_insert">
          </gallery>
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

I have succeeded in getting the pictures to show but it takes a very long time to run so I'm not sure if I've done it correctly. I used an array:

Sub PL_image(control As IRibbonControl, Index As Integer, ByRef image)

Dim fso As Object
Dim objfolder As Object
Dim obj, objfile As Object
Dim strpath As String
Dim imgpath As String
Dim imgname As String
Dim imgarray() As String
Dim x As Integer
Dim i As Double

strpath = "\\MYPATH\" 'Path to Picture Library

Set fso = CreateObject("Scripting.FileSystemObject")
Set objfolder = fso.GetFolder(strpath)
x = objfolder.Files.count
i = 0

ReDim imgarray(1 To x)
    For Each objfile In objfolder.Files
        imgname = objfile.Name
        imgname = Left(imgname, InStrRev(imgname, ".") - 1)
        i = i + 1
        imgarray(i) = imgname
    Next

Set image = LoadPicture(strpath & imgarray(Index) & ".jpg")
   
End Sub
0
 
LVL 23

Expert Comment

by:JSRWilson
ID: 40356499
Pretty sure it will always be slow on a network.
0
 

Author Closing Comment

by:Sim Kuch
ID: 40386219
This solution works, but it is very slow. This might always be the case when pulling pictures from a network though - I'm not sure. It's not really a viable solution for use in a corporate tool though, so I have downgraded it.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
vb6 connector to mongodb 2 82
XSLT Help 12 32
Need VB Script to scan through XML file and export content to csv file 9 32
XML response optional elements 12 40
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
PowerPoint is the go-to presentation software for millions of users around the world. Many presentations use basic text features but you can really make special text jump out of your slide by applying this bubble text design process. This article ha…
This video teaches viewers how to add simple and professional themes to their slides.
The viewer will learn how to edit text. This includes Font, Spacing, Resizing, Color, and other special text options.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question