473,473 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Writing my PowerPoint add-in into registry

2 New Member
Hi ,

I wrote some add in for PowerPoint and i'm trying to find an automatic way to load it every time PowerPoint starts.
I found Microsoft Code example (see below ) BUT the problem is :
I can't find all appear function declaration and VBA also errors regarding all the default variable values give in the code like ERROR_SUCCESS etc.
May be you can help me to make this code run??
Expand|Select|Wrap|Line Numbers
  1.  
  2. Function RegisterAddin( _
  3.       strBranch As String, _
  4.       strAddinName As String, _
  5.       strAddinPath, _
  6.         fAutoLoad As Boolean) As Boolean
  7.  
  8.       ' Turn on error trapping.
  9.       On Error GoTo RegAddinError
  10.       Err.Clear
  11.  
  12.       ' Create the variable used in the call to RegCreateKeyEx().
  13.       Dim lhkeyHive As Long
  14.       Dim strSubKey As String
  15.       Dim lhkey As Long
  16.       Dim lDisp As Long
  17.       Dim lReturnVal As Long
  18.  
  19.       ' Make the branch string all caps.
  20.       strBranch = UCase(strBranch)
  21.  
  22.       ' Determine which branch of the registry to use.
  23.       Select Case strBranch
  24.          Case Is = "LOCAL"
  25.             lhkeyHive = HKEY_LOCAL_MACHINE
  26.          Case Is = "L"
  27.             lhkeyHive = HKEY_LOCAL_MACHINE
  28.          Case Is = "CURRENT"
  29.             lhkeyHive = HKEY_CURRENT_USER
  30.          Case Is = "C"
  31.             lhkeyHive = HKEY_CURRENT_USER
  32.          Case Else
  33.             ' Passed in the wrong parameter, so use HKEY_LOCAL_MACHINE
  34.             lhkeyHive = HKEY_LOCAL_MACHINE
  35.       End Select
  36.  
  37.       ' Create the SubKey string.
  38.       strSubKey = "Software\Microsoft\Office\8.0\PowerPoint\AddIns\" & _
  39.          strAddinName
  40.  
  41.       ' Create or open the registry key.
  42.       lReturnVal = RegCreateKeyEx( _
  43.          lhkeyHive, _
  44.          strSubKey, _
  45.          0, _
  46.          "", _
  47.          REG_OPTION_NON_VOLATILE, _
  48.          KEY_ALL_ACCESS, _
  49.          vbNullString, _
  50.          lhkey, _
  51.          lDisp)
  52.  
  53.       ' See if error occurred when opening key.
  54.       If (lReturnVal <> ERROR_SUCCESS Or lhkey = 0) Then
  55.          RegisterAddin = False
  56.          Exit Function
  57.       End If
  58.  
  59.       'Add the path to the add-in to the registry.
  60.       lReturnVal = RegSetValueEx( _
  61.          lhkey, _
  62.          "Path", _
  63.          0&, _
  64.          REG_SZ, _
  65.          strAddinPath, _
  66.          Len(strAddinPath))
  67.  
  68.       ' See if an error occurred when writing the registry key.
  69.       If (lReturnVal <> ERROR_SUCCESS) Then
  70.          RegisterAddin = False
  71.          Exit Function
  72.       End If
  73.  
  74.       ' Add the AutoLoad key if needed.
  75.       If fAutoLoad = True Then
  76.  
  77.          'Add the path to the add-in to the registry.
  78.          lReturnVal = RegSetDwordValueEx( _
  79.             lhkey, _
  80.             "AutoLoad", _
  81.             0, _
  82.             REG_DWORD, _
  83.             &HFFFFFFFF, _
  84.             4)
  85.  
  86.             ' See if an error occurred when writing the registry key.
  87.             If (lReturnVal <> ERROR_SUCCESS) Then
  88.                RegisterAddin = False
  89.                Exit Function
  90.             End If
  91.  
  92.       End If
  93.  
  94.       ' Close the registry key.
  95.       lReturnVal = RegCloseKey(lhkey)
  96.  
  97.       ' See if error occurred when closing the registry key.
  98.       If (lReturnVal <> ERROR_SUCCESS) Then
  99.          RegisterAddin = False
  100.          Exit Function
  101.       End If
  102.  
  103.       ' All is well, so return true.
  104.       RegisterAddin = True
  105.  
  106.       ' Exit the sub so that the code does not flow into
  107.       ' the error handler.
  108.       Exit Function
  109.  
  110.    ' Handle an add-in registration error.
  111. RegAddinError:
  112.       RegisterAddin = False
  113.  
  114.       ' Close the registry key if it is still open.
  115.       If lhkey <> 0 Then
  116.          RegCloseKey lhkey
  117.       End If
  118.  
  119.    End Function
  120.  
  121. Function main()
  122.  
  123.  
  124.     If (RegisterAddin("HKEY_CURRENT_USER", "First.ppa", "C:\Documents and Settings\Administrator\Application Data\Microsoft\AddIns", True) = True) Then
  125.       MsgBox "It worked"
  126.    Else
  127.       MsgBox "it did not work"
  128.    End If
  129.    End Function
  130.  
  131.  
  132.  
May 16 '07 #1
1 1822
Dököll
2,364 Recognized Expert Top Contributor
Pushing this forward for all to see, good of you to add your code by the way...
May 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: careta | last post by:
Hello, I'm trying to automate PP creation from VB.net. The initial code is (as extracted from MSDN's KB209960): Public Sub Command1_Click() ' Start PowerPoint. Dim ppApp As...
0
by: asadhussain | last post by:
I am trying to automate conversion of powerpoint files to html. I have developed this as a windows service and here is the conversion code: .... PowerPoint.Application ppApp = new...
1
by: barry | last post by:
Would like to know the syntax to start a powerpoint presentation from a asp.net (vb.net) application thanks
0
by: NETRavi | last post by:
HI, For one of our ASP.NET project we are generating a business graph using a crystalreportviewer. The crystalreportviewer gives the possibility of exporting to .htm, .doc, . xls, .pdf, .rtf....
8
by: Rut | last post by:
Does anyone know how to start powerpoint from vb.net without the ppt screen appearing. I want to keep it hidden? Using this code: Try pp = New PowerPoint.Application pp.Visible =...
3
by: vegvegko | last post by:
Hi, Is there any way to build or distribute a C# application with a Powerpoint component, so that the application can display Powerpoint presentations on PCs that do not have Microsoft Office...
11
by: ssims | last post by:
1) Is it possible to create a powerpoint file with asp.net? I've Googled it and can't seem to find a definitive guide. 2) If it is possible to create a powerpoint file with asp.net, is it...
0
by: psuaudi | last post by:
i have a powerpoint presentation that uses links to other files and are put on the slide using OLE. The problem is that I have different users updating the information on the slides, which is not...
8
by: =?Utf-8?B?R2VvcmdlQXRraW5z?= | last post by:
Greetings! I wrote a small Exe that simply runs Shell to load PowerPoint and launch a particular file, depending on the day of the week. However, it was set up for office 2003 (I naively hardcoded...
0
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
Is there a website, or can someone show me how to open a Powerpoint template and add data to it using the OpenXML format? I am very new to using any type of XML, and really need a good example...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.