none
Printing Envelopes RRS feed

  • Question

  • Hi,

     

    I’m trying to set a Print() event to print out two envelopes, works fine but when it prints is coming out with the After Space Paragraph. Is there a way to remove that from VBA?

    Thanks

     

    Sub FilePrint()

    Dim DeliveryAddress As String

    Dim DeliveryAddress1 As String

    Dim oVars As Word.Variables

    Set oVars = ActiveDocument.Variables

    ToggleWatermark

    Dialogs(wdDialogFilePrint).Show

    ToggleWatermark

    DeliveryAddress = "Text" & vbCr & _

                        "Text" & vbCr & _

                        "Text"

    DeliveryAddress1 = oVars("varFirstName").Value & " " & oVars("varLastName").Value & vbCr & _

                        oVars("varAddress").Value & vbCr & _

                        oVars("varCity").Value & ", " & oVars("varState").Value & " " & oVars("varZip").Value

    ActiveDocument.Envelope.PrintOut , Address:=DeliveryAddress

    ActiveDocument.Envelope.PrintOut , Address:=DeliveryAddress1

    End Sub


    Thanks for everything, all your help is well appreciated
    Thursday, June 16, 2011 5:24 PM

Answers

  • How about Chr(11)?

    I just realized that I'd misremembered the character code for Word's new line.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by scorpdevil Friday, June 17, 2011 2:21 PM
    Friday, June 17, 2011 1:53 PM
    Moderator

All replies

  • Hi Scorpdevil

    <<works fine but when it prints is coming out with the After Space Paragraph.>>

    ??? Could you please provide more information about what you mean?

    Does this have something to do with the style definition applied to something on the envelope? If yes, change the style definition. In order to find out which style, click in the text that's a problem then look in the Styles Pane (assuming that's relevant to the version of Word involved, which you unfortunately do not mention).


    Cindy Meister, VSTO/Word MVP
    Friday, June 17, 2011 12:22 PM
    Moderator
  • Hi Cindy,

    Nice talking to you again, hope you're doing great.

    I’m using the code to print two envelopes when the user prints out the document. That part is working fine, but the font is coming out with a big separation in between.

     

    Example:

     

    I should print like this:

     

    Attention to you

    Address of your house

    City, State ZipCode

     

    Instead of:

     

    Attention to you

     

    Address of your house

     

    City, State ZipCode

     

    The entire font of the document has no Space After Paragraph and I believe that’s the problem with the font showing on the envelope.

     

    I’m using Word 2007; I believe that came out on 2007 version by default. Which I think is very annoying; I do not like that Space After Paragraph


    Thanks for everything, all your help is well appreciated
    Friday, June 17, 2011 12:39 PM
  • How about if you substitute Chr(10) for vbCr in your code where you concatenate the different parts of the address?

    FWIW the style "Envelope Address" has no SpaceAfter formatting for Envelopes when I create (add to the document) an envelope on my 2007 system. But using a new line character rather than a paragraph character should solve the problem in any case...


    Cindy Meister, VSTO/Word MVP
    Friday, June 17, 2011 12:45 PM
    Moderator
  • Nothing, still doing the same.

    I used it with vdNewLine and nothing.


    Thanks for everything, all your help is well appreciated
    Friday, June 17, 2011 1:32 PM
  • How about Chr(11)?

    I just realized that I'd misremembered the character code for Word's new line.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by scorpdevil Friday, June 17, 2011 2:21 PM
    Friday, June 17, 2011 1:53 PM
    Moderator
  • Nice!!!!! Very Nice!!

    Thanks A Lot


    Thanks for everything, all your help is well appreciated
    Friday, June 17, 2011 2:21 PM