none
Editing BuildingBlockTypes in Normal.dotm Word RRS feed

  • Question

  • I am trying to edit or delete a BuildingBlock from Normal.dotm file. And i am getting stuck in every direction i go. I think that could be possible with a VBA code. Saying that i have never coded a single VBA script/application.... Can someone with few min try to explain how do i run a VBA? Does it need to be compiled? Can i run it from command line if saved as a specific file type? 

    And maybe someone know if its possible to record a MACRO if a word "already recorded as a .bas" and run as a VBA? Do i need to change file type? Can this file be executed on other workstations?

    Thanks for the help.


    Tuesday, February 5, 2013 3:22 PM

All replies

  • Hi Ogeccut,

    Thanks for posting in the MSDN Forum.

    Please take a look at.

    Sub GetExistingBuildingBlock()
    
        Dim objTemplate As Template
        Dim objBB As BuildingBlock
        
        ' Set the template to store the building block
        Set objTemplate = ActiveDocument.AttachedTemplate
    
        ' Access the building block through the type and category
        Set objBB = objTemplate.BuildingBlockTypes(wdTypeCustomHeaders) _
            .Categories("Book Titles").BuildingBlocks("Title")
        
    End Sub

    It will let you get the BuildingBlock, then you can modify BuildingBlock's Value property to change it's content.

    I hope it can help you.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 6, 2013 1:43 AM
    Moderator
  • Thanks for helping. I have seen this script. However i got few questions. How do i identify BuildingBlockTypes? I think i know which Categories i need and BuildingBlocks is the text i need to update.

    And i think this is a vba? do i run vba's same way i would run a vbs? cscript scriptname.vbs?

    Again thanks for the help.

    Wednesday, February 6, 2013 6:04 PM
  • Hi Ogeccut,

     How do i identify BuildingBlockTypes? I think i know which Categories i need and BuildingBlocks is the text i need to update.
    Please reference http://msdn.microsoft.com/en-us/library/office/ff837878.aspx

    Vbs is quite different than VBA. And I'm afraid you need consult vbs in the special-purpose forum instead of discussing in this forum.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, February 7, 2013 4:08 AM
    Moderator
  • Thanks for trying to help. That was my question, how do i compile a VBA and what is the way to execute a VBA file??

    Thank you,

    Thursday, February 7, 2013 7:04 PM
  • Hi Ogeccut,

    VBA program is embedded in the host program such as Word, Excel, PowerPoint, Outlook, Microsoft Project etc. In Office suites you can call the VBA subroutine as a macro. If you want do it via code please use "Application.Run" method of your Office suite.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, February 8, 2013 2:19 AM
    Moderator
  • Tom, 

    Thanks for the reply. So my understating that VBA can only be run from the application such as Word, Excel, PowerPoint.....

    Is there a way to execute a VBA on windows? Say from a command prompt, or by double clicking on a file?

    If the answer is YES, what is the file extension? And is there a need to compile a VBA?

    I am trying to run a  script on few hundred clients remotely. And need to do a silent execution. 
    • Edited by Ogeccut Monday, February 11, 2013 2:29 PM
    Monday, February 11, 2013 2:26 PM
  • Hi Ogeccut, As far as I know, that VBA can be executed via host application's "Application.Run" method. However VBA can't execute without host application. You might use VBS script to approach your goal, however VBS is quite different than VBA. It is out of the technical range for this forum. I think it might be better support at http://social.technet.microsoft.com/Forums/en-US/ITCG/threads. Have a good day, Tom

    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, February 12, 2013 2:54 AM
    Moderator