?
Solved

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

Posted on 2014-09-29
7
Medium Priority
?
661 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction In all recent versions of PowerPoint it is possible to trigger animations. This means the animation takes place when a certain shape is clicked. This allows you to run animation “on demand” and outwith the normal sequence of mouse cl…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This video teaches viewers how to fit pictures into slides, crop and remove backgrounds, and alter photos to look more professional.
Suggested Courses

764 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