VBS InlineShape对齐& texttype宽度

时间:2018-04-17 17:34:54

标签: vbscript outlook alignment width horizontal-line

我是VBS for Outlook签名的新手。我把一切都搞定了,但无法弄清楚最后两件。

  1. 对于 objSelection.InlineShapes.AddHorizo​​ntalLineStandard ,我不知道如何将其对齐到左侧。如果我没有放宽度,它会覆盖整个电子邮件窗口,但我希望它的最大宽度为300px。

  2. 如何让objSelection的宽度也为300px?签名上的大部分副本都很好,这只是我要保持宽度限制的免责声明部分。

  3. 以下是代码。任何帮助将不胜感激!

        ' ########### Sets up word template
    
        Set objWord = CreateObject("Word.Application")
        Set objDoc = objWord.Documents.Add()
        Set objSelection = objWord.Selection
        objSelection.Style = "No Spacing"
        Set objEmailOptions = objWord.EmailOptions
        Set objSignatureObject = objEmailOptions.EmailSignature
        Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
    
    
    
        ' ########### Name, title, company
    
        objSelection.InlineShapes.AddHorizontalLineStandard.Width = 300
        objSelection.Font.Name = "Calibri"
        objSelection.Font.Size = 11
        objselection.Font.Bold = true
        objSelection.Font.Color = RGB (000,000,000)
    
        objSelection.TypeText strGiven & " " & strSurname
        objselection.TypeText Chr(11)
    
        objSelection.TypeText strTitle
        objselection.TypeText Chr(11)
    
        objselection.TypeText "Xtreme Manufacturing" & chr(153)
        objSelection.InlineShapes.AddHorizontalLineStandard.Width = 300
        objselection.TypeText Chr(11)
    
    
    
        ' ############ Logo
    
        Set objLink = objSelection.Hyperlinks.Add(objSelection.InlineShapes.AddPicture("https://www.xmfg.com/wp-content/themes/xmfg_s/images/email-sig/xmfg.gif"), "http://www.xmfg.com",,,"")
        objselection.TypeText Chr(11)
        objSelection.TypeParagraph()
    
    
    
        ' ############ Address
    
        objSelection.Font.Name = "Calibri"
        objSelection.Font.Size = 10
        objselection.Font.Bold = false
        objSelection.Font.Color = RGB (000,000,000)
    
        If (objUser.postofficebox = "") Then
    
        objSelection.TypeText strAddress1
        objselection.TypeText Chr(11)
    
        objSelection.TypeText strAddress2 & ", " & strAddress3 & " " & strPostCode
        objselection.TypeText Chr(11)
        objSelection.TypeParagraph()
    
        Else
    
        objSelection.TypeText strAddress1
        objselection.TypeText Chr(11)
    
        objSelection.TypeText strAddress1Ext
        objselection.TypeText Chr(11)
    
        objSelection.TypeText strAddress2 & ", " & strAddress3 & " " & strPostCode
        objselection.TypeText Chr(11)
        objSelection.TypeParagraph()
    
        End If
    
    
        ' ########### Phone, mobile, fax
    
        Set objRange = objSelection.Range
        objDoc.Tables.Add objRange, 3,2
        Set objTable = objDoc.Tables(1)
    
        objTable.AutoFitBehavior(1)
        objTable.leftpadding = 0.4
        objTable.rightpadding = 0
    
        objTable.Cell(1, 1).Range.Text = "T"
        objTable.Cell(1, 2).Range.Text = ": +1 " & strPhone & " " & "ext " & strExt
    
        objTable.Cell(2, 1).Range.Text = "M"
        objTable.Cell(2, 2).Range.Text = ": +1 " & strMobile
    
        objTable.Cell(3, 1).Range.Text = "F"
        objTable.Cell(3, 2).Range.Text = ": +1 " & strFax
    
        objSelection.EndKey 6
    
    
    
        ' ########### Website
    
        Const wdParagraph = 3
        Const wdExtend = 1
        Const wdCollapseEnd = 0
    
        Set objLink = objSelection.Hyperlinks.Add(objSelection.Range,    "http://www.xmfg.com", , , "www.xmfg.com")
        objLink.Range.Font.Size = 10
        objLink.Range.Font.Bold = true
        objSelection.Font.Name = "Calibri"
        objselection.TypeText Chr(11)
        objSelection.TypeParagraph()
    
        objSelection.StartOf wdParagraph, wdExtend
        objSelection.Font.Color = RGB(000,000,000)
        objSelection.Collapse wdCollapseEnd
    
    
    
        ' ########### Disclaimer
    
        objSelection.Font.Name = "Calibri"
        objSelection.Font.Size = 8
        objselection.Font.Bold = false
        objSelection.Font.Color = RGB (000,000,000)
        objSelection.Textwidth = 3
    
        objSelection.TypeText "The email and attachments hereto are strictly confidential and intended solely for the addressee. If you are not the intended addressee, please notify the sender by return and delete the message. You must not disclose, forward or copy this email or attachments to any third party without prior consent of the sender."
        objselection.TypeText Chr(11)
        objSelection.TypeParagraph()
    
        objSelection.TypeText "The Xtreme Manufacturing name and logos, and all related product and service names, design marks and slogans are the trademarks of Xtreme Manufacturing. All rights are expressly reserved herein. Any reproduction, copies, or exploitation in any manner and for any purpose without the express written consent of Xtreme Manufacturing is strictly prohibited. "
        objselection.TypeText Chr(11)
        objSelection.TypeParagraph()
    

1 个答案:

答案 0 :(得分:0)

我能够将水平线格式化:

With objSelection.InlineShapes.AddHorizontalLineStandard
     .Width = 200
     .HorizontalLineFormat.Alignment = 0
End With