Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Import module to normal.dot (2000 / 2003)

    Hi I am using the below code from a command button on a word doc to import modules, the idea is to email the file to everyone and get them to click the button. The only problem is that the modules import to the document with the button and not to the normal .doc has I had hoped.

    Unfortunatley I can not just replace there normal.dot as this looses the users autotext at the same time.

    Many thanks

    Sub MergeModules()
    ' Import Modules
    Application.VBE.ActiveVBProject.VBComponents.Impor t ("H:ScriptsSLSModulesGetUserLogon.bas")
    Application.VBE.ActiveVBProject.VBComponents.Impor t ("H:ScriptsSLSModulesHelp.bas")
    Application.VBE.ActiveVBProject.VBComponents.Impor t ("H:ScriptsSLSModulesInsertTemplates.bas")
    Application.VBE.ActiveVBProject.VBComponents.Impor t ("H:ScriptsSLSModulesPatientLetterOpenAndFormat.ba s")
    Application.VBE.ActiveVBProject.VBComponents.Impor t ("H:ScriptsSLSModulesPrinterTray.bas")
    Application.VBE.ActiveVBProject.VBComponents.Impor t ("H:ScriptsSLSModulesSendEmailAttachments.bas")
    Application.VBE.ActiveVBProject.VBComponents.Impor t ("H:ScriptsSLSModulesSLSToolbar.bas")
    Application.VBE.ActiveVBProject.VBComponents.Impor t ("H:ScriptsSLSModulesSpellChecker.bas")
    Application.VBE.ActiveVBProject.VBComponents.Impor t ("H:ScriptsSLSModulesTextLogAndEmail.bas")
    Application.VBE.ActiveVBProject.VBComponents.Impor t ("H:ScriptsSLSModulesUserNetCode.bas")

    End Sub
    Regards
    Gerbil (AKA Kevin)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import module to normal.dot (2000 / 2003)

    Does it work if you use Application.VBE.VBProjects("Normal") instead of Application.VBE.ActiveVBProject ?

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import module to normal.dot (2000 / 2003)

    An alternative would be to store all modules in a document or template and to use Application.OrganizerCopy to transfer the modules, e.g.:

    Application.OrganizerCopy Source:="H:SourceSource.doc", Destination:=NormalTemplate.FullName, _
    Name:="GetUserLogon", Object:=wdOrganizerObjectProjectItems

  4. #4
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import module to normal.dot (2000 / 2003)

    Hans, Thanks your first option worked perfect yet again I made a simple mistake I had forgotten the " " around the word normal.

    I now have a module to import and remove the modules. I am now trying to figure out how to check if a module exsits below is what I have tried it works if it does exsit but not if it does not. The only thing I can think of is using On Error Resume next, but I want to use this code to check if a module exsits and if not import it, if it does remove it first then import it.

    Many thanks

    Sub UpdateSLSToolbar()
    Dim VBC As VBComponent

    'Removes old versions if they exsit and copies latest modules into the normal.dot

    If Application.VBE.VBProjects("Normal").VBComponents. Item("DateChecker").Name = "DateChecker" Then
    MsgBox "Yes", vbInformation
    Else
    MsgBox "No", vbInformation
    End If

    End Sub
    Regards
    Gerbil (AKA Kevin)

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import module to normal.dot (2000 / 2003)

    You can either delete the module unconditionally with an On Error Resume Next to suppress the error message if the module doesn't exist:

    On Error Resume Next
    Application.VBE.VBProjects("Normal").VBComponents. Remove("DateChecker")
    On Error GoTo 0 ' or to an error handler

    or you can loop through the VBComponents to see of you find the one you want to remove, but that's more work.

Posting Permissions

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