VBA listbox that makes single slicer selection

Krisla

New Member
Joined
Oct 7, 2014
Messages
11
Dear community,

I am very new to VBA, and my request might be basic but I struggled to find clear instruction on how to do it...

I am building a macro that creates a Powerpoint presentation for each slicer selction (slicer is connected to multiple tables and views). Only 1 slicer where I have to select 1 brand at the time, and it will create the presentation and save it with the selected brand name.

I have a listbox where you hve to doubleclick the brand, but how do I connect this box selection to my slicer?

Private Sub DivisionName_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

The rest of the macro is ready...

Sub CreatePowerPoint()
Dim myPresentation As PowerPoint.Presentation
Dim TemplateLocation As String
Dim PowerPointApp As PowerPoint.Application
Dim activeSlide As PowerPoint.Slide
Dim cht As Excel.ChartObject



'Opens Template PowerPoint
Set PowerPointApp = CreateObject("PowerPoint.Application")
TemplateLoaction = "C:\Users\kslavulj\Desktop\POWERPOINT Automation\Template\EMEA SIOP Template.pptx"
PowerPointApp.Presentations.Open (TemplateLoaction)
.................


Let me know if you need any further information


Thanks

Krisla
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Let's start with the following, with this code you will open a PowerPoint and save it with the selected data in the listbox with double click

Code:
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)


    Dim ObjPowerPoint As New PowerPoint.Application
    Dim Presentacion As PowerPoint.Presentation
    Dim activeSlide As PowerPoint.Slide
    Dim TemplateLocation As String
    Dim wName As String, wPath As String
    '
    wPath = "C:\Users\kslavulj\Desktop\POWERPOINT Automation\Template\"
    'wPath = ThisWorkbook.Path & "\"
    If Right(wPath, 1) <> "\" Then wPath = wPath & "\"
    wName = ListBox1.List(ListBox1.ListIndex)
    '
    TemplateLocation = ThisWorkbook.Path & "\EMEA SIOP Template.pptx"
    ObjPowerPoint.Visible = True
    ObjPowerPoint.Presentations.Open Filename:=TemplateLocation
    Set myPresentation = ObjPowerPoint.ActivePresentation
    '
    myPresentation.SaveAs wPath & wName & ".pptx"
    myPresentation.Close
    ObjPowerPoint.Quit
    
    Set myPresentation = Nothing


End Sub




I guess the next part is putting information in the slicer, but I did not understand what you're going to put.

Let me know if you have any question.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top