A question about Alignment using the Word object

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jerry Rhodes (Jerry.Rhodes_at_nordstrom.com)
Date: 04/08/04


Date: 8 Apr 2004 07:18:37 -0700

I am using the Word 2000 object to perform a mailmerge from an SQL
Server table. I would like for the upper left corner to contain a JPG
and return address, with the customer address centered below that.
The JPG is being left aligned, but the return address is being
centered. Why is the return address being centered? Here's the code.
 Thanks for any help!!

Sub AutoOpen()
    ActiveDocument.MailMerge.MainDocumentType = wdMailingLabels
Mailing;UID=xjlr;APP=Microsoft®
Query;WSID=W0310011;DATABASE=CheckingNewAcctCallIn;Trusted_Connection=Yes"
_
    ' , SQLStatement:= _
    ' "SELECT CheckingNewAcctCallIn.FirstName,
CheckingNewAcctCallIn.LastName, CheckingNewAcctCallIn.Address1,
CheckingNewAcctCallIn.City, CheckingNewAcctCallIn.State,
CheckingNewAcctCallIn.PostalCode FROM
CheckingNewAcctCallIn.dbo.CheckingNewAcctCallIn Checkin" _
    ' , SQLStatement1:= _
    ' "gNewAcctCallIn ORDER BY CheckingNewAcctCallIn.LastName,
CheckingNewAcctCallIn.FirstName"
    ActiveDocument.MailMerge.OpenDataSource Name:="",
ConfirmConversions:= _
        False, ReadOnly:=False, LinkToSource:=False,
AddToRecentFiles:=False, _
        PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
        WritePasswordTemplate:="", Revert:=False,
Format:=wdOpenFormatAuto, _
        Connection:= _
        "DSN=CheckingNewAcctCallIn;Description=New Checking Acct Info
Mailing;UID=xjlr;APP=Microsoft®
Query;WSID=W0310011;DATABASE=CheckingNewAcctCallIn;Trusted_Connection=Yes"
_
        , SQLStatement:= _
        "SELECT CheckingNewAcctCallIn.FirstName,
CheckingNewAcctCallIn.LastName, CheckingNewAcctCallIn.Address,
CheckingNewAcctCallIn.City, CheckingNewAcctCallIn.State,
CheckingNewAcctCallIn.Zip, CheckingNewAcctCallIn.PrintNow FROM
CheckingNewAcctCallIn.dbo.Check" _
        , SQLStatement1:= _
        "ingNewAcctCallIn CheckingNewAcctCallIn WHERE
(CheckingNewAcctCallIn.PrintNow='Y') ORDER BY
CheckingNewAcctCallIn.LastName, CheckingNewAcctCallIn.FirstName"
    Application.MailingLabel.DefaultPrintBarCode = False
    With ActiveDocument.MailMerge
        With .Fields
            Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
            Selection.InlineShapes.AddPicture FileName:="D:\Bank.jpg",
LinkToFile:= _
                      True
            Selection.TypeText Text:=vbCrLf
            Selection.Font.Bold = True
            Selection.Font.Size = 10
            Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
            Selection.TypeText Text:="PO Box 11, ReturnCity, CO 80123"
            Selection.ParagraphFormat.Alignment =
wdAlignParagraphCenter
            Selection.TypeText Text:=vbCrLf
            .Add Range:=Selection.Range, Name:="FirstName"
             Selection.TypeText Text:=" "
            .Add Range:=Selection.Range, Name:="LastName"
             Selection.TypeText Text:=vbCrLf
            .Add Range:=Selection.Range, Name:="Address"
             Selection.TypeText Text:=vbCrLf
            .Add Range:=Selection.Range, Name:="City"
             Selection.TypeText Text:=", "
            .Add Range:=Selection.Range, Name:="State"
             Selection.TypeText Text:=" "
            .Add Range:=Selection.Range, Name:="Zip"
             Selection.TypeText Text:=vbCrLf
        End With
        Dim oAutoText As Word.AutoTextEntry
        Set oAutoText =
NormalTemplate.AutoTextEntries.Add("LabelLayout",
ActiveDocument.Content)
        ActiveDocument.Content.Delete
        Application.MailingLabel.CreateNewDocument Name:="5163",
Address:="", _
                    AutoText:="LabelLayout",
LaserTray:=wdPrinterDefaultBin
        .Destination = wdSendToPrinter
        .MailAsAttachment = False
        .MailAddressFieldName = ""
        .MailSubject = ""
        .SuppressBlankLines = True
        With .DataSource
            .FirstRecord = wdDefaultFirstRecord
            .LastRecord = wdDefaultLastRecord
        End With
        .Execute Pause:=True
        oAutoText.Delete
    End With
    ActiveDocument.Close False
    Application.Visible = True
    Application.NormalTemplate.Saved = True

End Sub



Relevant Pages

  • Re: Can Exploit-ANIfile.c infect JPG files?
    ... | JPG. ... The server was ... | off line and fully scanned (VirusScan plus tools used our security group to ... and exploitable vulnerabilities that may have led to the hacking of then server. ...
    (microsoft.public.security.virus)
  • Re: mime types
    ... when uploading a jpg or jpeg this works fine in firefox but when i try ... embedded in any image on an unprotected server can give server-wise ...
    (alt.php)
  • Re: .jpg files slow to open
    ... open a .jpg and display the preview using the picture/fax viewer. ... I am troubleshooting another machine (Vista) that is having the exact same ... is what brought me to notice that the server itself can't open the files ...
    (microsoft.public.windows.server.general)
  • .jpg files slow to open
    ... open a .jpg and display the preview using the picture/fax viewer. ... it is only the initial opening that is slow. ... is what brought me to notice that the server itself can't open the files ...
    (microsoft.public.windows.server.general)
  • Realtime Antivirus - Speed comparisons.
    ... I have a server with many tens of thousands of .JPG ... I am running eTrust antivirus 7.0 on the server and ... If I disable Inoculan on my machine and the server, ...
    (alt.comp.anti-virus)