Consulting

Results 1 to 6 of 6

Thread: ThisPresentation for an Add-In file

  1. #1

    Question ThisPresentation for an Add-In file

    I know that in PowerPoint VBA there is now such thing as ThisPresentation. I need to set a variable however the presentation the VBA code is stored to. I have been able to do this by using the file name, for example I could write:

    Set ThisPresentation = Presentations("Custom Macros.pptm")
    However if I try to do this with an add-in file it doesn't seem to work, for example I tried:

    Set ThisPresentation = Presentations("Custom Macros.ppam")

    Are there any other ways to set a variable to the add-in file in PowerPoint? I am trying to create a userform add-in that can variably updated listbox that eventually populates an Array. My problem is that I want the userform to remember the listbox items after PowerPoint is closed so next time you don't have to re-enter the items in the listbox. I was accomplishing this by having VBA rewrite its own code.
    Chris Macro

    The Spreadsheet Guru
    Using Office 2007 (Windows 7) & Office 2013 (Windows 8)
    Twitter | Facebook| Google+

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    You can store the values in a textfile or in registry keys (I would do this) which is saved and read when the list changes and when the AddIn loads. They cannot be stored within the ppam AFAIK

    Look at SaveSetting and GetSetting
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    I thought about doing that (a registry key) but was hopeful that there might be an alternative solution. My biggest concern was when I shared the add-in that I wanted to have some default items pre-populated in the listbox. I suppose I could just make an IF statement to check and see if a specific registry was made or not. Thanks for your advice John!
    Chris Macro

    The Spreadsheet Guru
    Using Office 2007 (Windows 7) & Office 2013 (Windows 8)
    Twitter | Facebook| Google+

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    If you use getSetting Chris you can specify the default value if the reg key is absent.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    Oh, didn't know that. Let me play around with it and I'll let you know if I run into problems.
    Chris Macro

    The Spreadsheet Guru
    Using Office 2007 (Windows 7) & Office 2013 (Windows 8)
    Twitter | Facebook| Google+

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    So for example

    strInput1 = GetSetting("Chris", "Data", "Val1", "John")

    Will set strInput1 to John if there is no key at

    HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Chris\Data\Val1

    If the key exists strInput1 will be set to the value of that key
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •