none
Bolding Address in Labels w/ Word Automation? RRS feed

  • Question

  • I have a unique problem. Right now, I'm creating a single label on an label sheet using

    ActiveDoc = oWord.Application.MailingLabel.CreateNewDocumentByID(labelID:=AveryType)

    and then adding 3 paragrpahs of info like a normal word doc using Paragraph.Add, etc. on the first label.

    The problem is that I would like to create a full page of labels, and I know you can use

    address:="The Text"

    for full page of labels of that text, but it's 3 different paragraphs, and the first paragraph is user selectable to be Bold or not. Using Cell selects like a normal word doc after the label sheet is created and doing it won't work because different labels have different spacer cells (how many, where, etc.).

    I know inside Word in the Labels dialog you can right click the Address and bold it, etc.

    So how can I do this programmatically? Anyone have any code or ideas?

    Massive thanks!


    • Edited by ChrisF8657 Monday, December 29, 2014 8:15 PM
    • Moved by Carl Cai Tuesday, December 30, 2014 2:22 AM more related
    Monday, December 29, 2014 8:14 PM

Answers

  • Hi Chris,

    Based on the description, you are creating a full page of label and you want to bold the address.

    >>I know inside Word in the Labels dialog you can right click the Address and bold it, etc.<<

    To get the similar code responding to the manual operation, we can use Record a macro, and here is the code for your reference:

    Sub Macro1()
    
        Application.MailingLabel.DefaultPrintBarCode = False
        Application.MailingLabel.CreateNewDocumentByID LabelID:="16907267", _
              Address:="Addrees1", AutoText:="ToolsCreateLabels1", LaserTray:= _
            wdPrinterManualFeed, ExtractAddress:=False, PrintEPostageLabel:=False, _
            Vertical:=False
    End Sub
     

    And based on the code above, the macro added an building block entry named "ToolsCreateLabels1" for us to bold the address.

    Also we can add the building block entry programmatically, here is the code:

    Sub addBuildingBlock()
    Dim objTemplate As Template
    Dim objBB As BuildingBlock
     
    With Application.Selection
     .Range.Text = "Address"
     .Range.Bold = True
     .Expand
     End With
     
    Set objTemplate = Templates("Normal.dotm")
     
    Set objBB = objTemplate.BuildingBlockEntries _
     .Add(Name:="ToolsCreateLabels6", _
     Type:=wdTypeQuickParts, _
     Category:="General", _
     Range:=Selection.Range)
    
    End Sub

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by ChrisF8657 Thursday, January 1, 2015 7:01 PM
    Tuesday, December 30, 2014 6:43 AM
    Moderator

All replies

  • Hello,

    Since this issue is mainly related to using Word object module, I have helped you move this thread to more related forum to get support.

    Regards.

    Carl


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 30, 2014 2:23 AM
  • Hi Chris,

    Based on the description, you are creating a full page of label and you want to bold the address.

    >>I know inside Word in the Labels dialog you can right click the Address and bold it, etc.<<

    To get the similar code responding to the manual operation, we can use Record a macro, and here is the code for your reference:

    Sub Macro1()
    
        Application.MailingLabel.DefaultPrintBarCode = False
        Application.MailingLabel.CreateNewDocumentByID LabelID:="16907267", _
              Address:="Addrees1", AutoText:="ToolsCreateLabels1", LaserTray:= _
            wdPrinterManualFeed, ExtractAddress:=False, PrintEPostageLabel:=False, _
            Vertical:=False
    End Sub
     

    And based on the code above, the macro added an building block entry named "ToolsCreateLabels1" for us to bold the address.

    Also we can add the building block entry programmatically, here is the code:

    Sub addBuildingBlock()
    Dim objTemplate As Template
    Dim objBB As BuildingBlock
     
    With Application.Selection
     .Range.Text = "Address"
     .Range.Bold = True
     .Expand
     End With
     
    Set objTemplate = Templates("Normal.dotm")
     
    Set objBB = objTemplate.BuildingBlockEntries _
     .Add(Name:="ToolsCreateLabels6", _
     Type:=wdTypeQuickParts, _
     Category:="General", _
     Range:=Selection.Range)
    
    End Sub

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by ChrisF8657 Thursday, January 1, 2015 7:01 PM
    Tuesday, December 30, 2014 6:43 AM
    Moderator
  • Hi Fei,

    Thanks, that helped, but it wasn't exactly what I was looking for - it did give me an idea however, and I was able to accomplish what I needed, so thanks!

    Thursday, January 1, 2015 7:15 AM