我正在制作一个从AD中提取信息的VBS脚本,并在AD中创建一个很好的签名,包含在签名中的信息。
现在代码我已经完美地工作并完成了所需的工作。
这是代码
On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
Set WshShell = CreateObject("WScript.Shell")
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
strName = objUser.FullName
strFname = objUser.FirstName
strLname = objUser.LastName
strTitle = objUser.title
strCompany = objUser.company
strCred = objUser.info
strStreet = objUser.StreetAddress
strLocation = objUser.l
strCity = objUser.st
strPostCode = objUser.PostalCode
strPhone = objUser.TelephoneNumber
strMobile = objUser.Mobile
strFax = objUser.FacsimileTelephoneNumber
strEmail = objUser.mail
strWeb = objuser.wWWHomePage
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
Set objSelection1 = objWord.Selection1
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
'Hyperlink Style
objDoc.Styles("Hyperlink").Font.Color = RGB(255, 102, 0)
objDoc.Styles("Hyperlink").Font.Size = 9
objDoc.Styles("Hyperlink").Font.Name = "Calibri"
'Kind Regards
objSelection.Font.Color = RGB(64,64,64)
objSelection.Font.Name = "Calibri"
objSelection.Font.Size = 12
objSelection.TypeParagraph()
objSelection.TypeText "Kind regards,"
objSelection.TypeText Chr(11)
'FirstName LastName
objSelection.Font.Name = "Calibri"
objSelection.Font.Size = 11
objSelection.Font.Color = RGB(64,64,64)
objSelection.TypeText Chr(11)
objSelection.Font.Bold = True
if (strFname) Then objSelection.TypeText strFname
if (strLname) Then objSelection.TypeText " " & strLname & Chr(11)
objSelection.Font.Bold = False
'Job Title
objSelection.Font.Name = "Calibri"
objSelection.Font.Size = 11
objSelection.Font.Color = RGB(64,64,64)
if (strTitle) Then objSelection.TypeText strTitle & Chr(11)
'Company Name
objSelection.Font.Name = "Calibri"
objSelection.Font.Size = 11
objSelection.Font.Color = RGB(64,64,64)
if (strCompany) Then objSelection.TypeText strCompany & Chr(11)
'Swann Logo
Set objShape = objSelection.InLineShapes.AddPicture("http://www.swanngroupltd.com/sig500.jpg")
objSelection.TypeText " "
objSelection.Font.Size = 2
objSelection.TypeText Chr(11)
objSelection.Font.Size = 9
'Variables from AD
objSelection.Font.Name = "Calibri"
objSelection.Font.Size = 9
objSelection.Font.Color = RGB(64,64,64)
if (strPhone) Then objSelection.TypeText "t: " & strPhone & Space(2)
if (strMobile) Then objSelection.TypeText "m: " & strMobile & Space(2)
if (strFax) Then objSelection.TypeText "Fax: " & strFax & Chr(11)
'Email
objSelection.TypeText Chr(11)
objselection.typeText "e: " & strEmailTEXT
Set objLink = objSelection.Hyperlinks.Add(objSelection.Range, "mailto: " & strEmail, , , strEmail)
objSelection1.Font.Color = RGB(255,102,0)
objSelection.TypeText Chr(11)
'Variables from AD
objSelection.Font.Name = "Calibri"
objSelection.Font.Size = 9
objSelection.Font.Color = RGB(64,64,64)
if (strStreet) Then objSelection.TypeText "" & strStreet & Space(1)
if (strLocation) Then objSelection.TypeText ", " & strLocation & Space(1)
if (strCity) Then objSelection.TypeText ", " & strCity & Space(1)
if (strPostCode) Then objSelection.TypeText ", " & strPostCode & Chr(11)
'Company Registration
objSelection.Font.Name = "Calibri"
objSelection.Font.Size = 9
objSelection.Font.Color = RGB(64,64,64)
objSelection.TypeText "Company Registration No: 1164271 VAT Registered No: 104453212"
'Please Visit Us
objSelection.TypeText Chr(11)
objSelection.Font.Name = "Calibri"
objSelection.Font.Size = 9
objSelection.TypeText Chr(11)
objSelection.TypeText "Please visit us at:"
objSelection.TypeText Chr(11)
'URL1
objSelection.Font.Name = "Calibri"
objSelection.Font.Bold = False
objSelection.Font.Size = "9"
objSelection.Font.Color = RGB(255,102,0)
objLink = objSelection.Hyperlinks.Add(objSelection.Range,"http://www.swanngroupltd.com",,"Swann Group Ltd", "www.swanngroupltd.com")
objSelection.TypeText Space(2)
'URL2
objSelection.Font.Name = "Calibri"
objSelection.Font.Bold = False
objSelection.Font.Size = "9"
objLink = objSelection.Hyperlinks.Add(objSelection.Range,"http://www.towermaster.co.uk",,"Towermaster", "www.towermaster.co.uk")
objSelection.TypeText Space(2)
'URL3
objSelection.Font.Name = "Calibri"
objSelection.Font.Bold = False
objSelection.Font.Size = "9"
objLink = objSelection.Hyperlinks.Add(objSelection.Range,"http://www.swanndirect.com",,"Swann Direct", "www.swanndirect.com")
objSelection.Font.Color = RGB(255,102,0)
objSelection.TypeText Chr(11)
objSelection.TypeText Chr(11)
'Towermaster
Set objLink = objSelection.Hyperlinks.Add(objSelection.InlineShapes.AddPicture("http://www.swanngroupltd.com/towermaster.jpg"), "http://www.towermaster.co.uk",,,"")
objSelection.TypeText Chr(11)
objSelection.TypeText Chr(11)
'Accreditation Logo
Set objLink = objSelection.Hyperlinks.Add(objSelection.InlineShapes.AddPicture("http://www.swanngroupltd.com/Sig-Acc.png"), "http://www.swanngroupltd.com",,,"")
'Disclaimer
objSelection.TypeText Chr(11)
objSelection.Font.Name = "Calibri"
objSelection.Font.Size = 9
objSelection.Font.Color = RGB(64,64,64)
objSelection.TypeText Chr(11)
objSelection.TypeText "Please consider the environment before printing this email"
objSelection.TypeText Chr(11)
objSelection.TypeText "The information transmitted in this e-mail and its attachments is intended only for the person or entity to which it is addressed and may contain confidential and/or legally privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you receive this in error, please contact the sender and delete the material from any computer. We will not accept responsibility for any commitments made by our employees outside the scope of our business and offer no warrant to the accuracy or completeness of such information."
Set objSelection = objDoc.Range()
'Name of Signature in Outlook
objSignatureEntries.Add "Swann Formal Signature", objSelection
objSignatureObject.NewMessageSignature = "Swann Formal signature"
objSignatureObject.ReplyMessageSignature = "Swann Formal Signature"
objDoc.Saved = True
objWord.Quit
现在我被要求将布局更改为类似
http://i.stack.imgur.com/d6vmC.png
正如您在底部看到的那样是桌子的形状。
如何将当前代码转换为此表? 我提前感谢任何可以提供帮助的人,因为VBS不是我的强项,而且我已经走到了这一步......