Results 1 to 2 of 2

Thread: Word 2010 add-ins not working with macro code

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    18
    Rep Power
    0

    Word 2010 add-ins not working with macro code

    I have this add-ins that can protect and unprotect a word document, my problem is when I copy the file to the C:\Users\username\AppData\Roaming\Microsoft\Word\S TARTUP, It supposed to run in start up of word. but the thing is its not, its file extension is *.dotm. when I run/open the file the add-ins is running fine,it is showing in the document. that is why I think its working. All is fine with my word settings because i tried to add some add-ins and its working i mean its showing.

    Here is my code for Add-ins
    Code:
    Private Sub Document_Open()
    
        Call AddInView
    
    End Sub
    
    
    Private Sub AddInView()
    
    Const strMenName As String = "PW Protection"
    
    
    Dim cCurrBar As CommandBar
    Dim cExtraMenu As CommandBarControl
    Dim cAddInnPopup As CommandBarPopup
    
    Dim cMenItem01 As CommandBarControl, cMenItem02 As CommandBarControl
    Dim iStart As Integer, iEnd As Integer
    Dim cMenItem01a As CommandBarControl, cMenItem01b As CommandBarControl
    
    
      iEnd = Application.CommandBars(1).Controls.Count
      For iStart = 1 To iEnd
        If Application.CommandBars(1).Controls(iStart).Caption = strMenName Then Exit Sub
      Next iStart
    
      Set cCurrBar = Application.CommandBars.ActiveMenuBar
      Set cExtraMenu = cCurrBar.Controls.Add(Type:=msoControlPopup, Temporary:=True, Before:=8)
      cExtraMenu.Caption = strMenName
    
      Set cMenItem01 = cExtraMenu.Controls.Add(Type:=msoControlButton)
      With cMenItem01
        .Caption = "Protect Document"
        .OnAction = "ProtectDocument"
      End With
    
      Set cMenItem02 = cExtraMenu.Controls.Add(Type:=msoControlButton)
      With cMenItem02
        .Caption = "Unprotect Document"
        .OnAction = "UnProtectDocument"
      End With
    
    End Sub
    And here is my code for the protect and unprotect macro which will be call in add-ins

    Code:
    Sub ProtectDocument()
    
        Dim Pwd             As String
    
        If ActiveDocument.ProtectionType = wdNoProtection Then
    
        Pwd = InputBox("Enter your password to protect the document", "Password Input")
    
            ActiveDocument.Protect NoReset:=True, _
            Password:=Pwd, _
            Type:=wdAllowOnlyReading
    
        Else
            MsgBox "Document is Protected"
        End If
    
    End Sub
    
    Sub UnProtectDocument()
    
    Dim Pwd             As String
    
    On Error GoTo ProtectNoResetErr
    
        If ActiveDocument.ProtectionType <> wdNoProtection Then
    
        Pwd = InputBox("Enter your password to unprotect the document", "Password Input")
    
             ' Unprotect the document.
             ActiveDocument.Unprotect Password:=Pwd
    
        Else
            MsgBox "Document is UnProtected"
    
        End If
    
    ProtectNoResetErr:
    If Err <> 0 Then MsgBox Err.Description
    
    
    End Sub

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Did you try Addins Won't AutoOpen - Word 2010 - Microsoft Community

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNsaS3Lp1
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgR1EPUkhw
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNe_XC-jK
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNPOdiDuv
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgN7AC7wAc
    https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm 9wlhQrYJP3M
    https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg
    https://www.youtube.com/watch?v=DVFFApHzYVk&lc=Ugyi578yhj9zShmhuPl4AaABAg
    https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgxvxlnuTRWiV6MUZB14AaABAg
    https://www.youtube.com/watch?v=_8i1fVEi5WY&lc=Ugz0ptwE5J-2CpX4Lzh4AaABAg
    https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxoHAw8RwR7VmyVBUt4AaABAg. 9C-br0lEl8V9xI0_6pCaR9
    https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=Ugz5DDCMqmHLeEjUU8t4AaABAg. 9bl7m03Onql9xI-ar3Z0ME
    https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxYnpd9leriPmc8rPd4AaABAg. 9gdrYDocLIm9xI-2ZpVF-q
    https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgyjoPLjNeIAOMVH_u94AaABAg. 9id_Q3FO8Lp9xHyeYSuv1I
    https://www.reddit.com/r/windowsxp/comments/pexq9q/comment/k81ybvj/?utm_source=reddit&utm_medium=web2x&context=3
    https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg
    https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm 9wlhQrYJP3M
    ttps://www.youtube.com/watch?v=LP9fz2DCMBE
    https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg
    https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg. 9wdo_rWgxSH9wdpcYqrvp8
    ttps://www.youtube.com/watch?v=bFxnXH4-L1A
    https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxuODisjo6cvom7O-B4AaABAg.9w_AeS3JiK09wdi2XviwLG
    https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxBU39bTptFznDC1PJ4AaABAg
    ttps://www.youtube.com/watch?v=GqzeFYWjTxI
    https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgwJnJDJ5JT8hFvibt14AaABAg
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 11-30-2023 at 03:17 PM.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Ribbon Calendar DatePicker Word 2007-2010
    By Excel Fox in forum Download Center
    Replies: 24
    Last Post: 09-23-2013, 09:07 AM
  2. Stock Market Add-In Not Working In Excel 2010
    By Subu123 in forum Excel Help
    Replies: 3
    Last Post: 07-16-2013, 07:12 AM
  3. Replies: 3
    Last Post: 06-26-2013, 11:42 PM
  4. Add ribbon programmatically to Excel 2010 using VBA
    By heapifyman in forum Excel Ribbon and Add-Ins
    Replies: 6
    Last Post: 07-18-2011, 09:16 PM
  5. Using Add-Ins/XLAM files
    By Rasm in forum Download Center
    Replies: 1
    Last Post: 04-07-2011, 11:27 AM

Posting Permissions

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