Outlook handtekening in VBA

  • Onderwerp starter Onderwerp starter Stag
  • Startdatum Startdatum
Status
Niet open voor verdere reacties.

Stag

Gebruiker
Lid geworden
10 jan 2013
Berichten
9
Goedemorgen iedereen,

Ik ben bezig met het maken van een Outlook handtekening met VBA. Tot nog toe lukt het behoorlijk goed, maar ik heb een vraag.

Nu wil ik graag een tab toevoegen, ik ben erachter gekomen dat dit kan met het commando objSelection.TypeText Chr(9). Weet iemand hier misschien een commando om de afstand van de tab kleiner te maken, standaard is deze namelijk te groot.

ik hoop dat iemand me kan helpen! Alvast bedankt!
 
Het typen van een tab is simpel; daarbij gebeurt niet veel anders dan dat de cursor naar de eerstvolgende ingestelde tabpositie gaat. Het instellen van tabs is een ander verhaal. Dat zul je ook met VBA moeten doen, als je een nieuwe positie wilt. Probleem is dan, als je nieuwe alinea's maakt, dat die tabinstelling dan bij alle volgende alinea's ook blijft staan, en je zult dus aan het eind van de procedure de tabs weer moeten resetten.

Code:
    Selection.ParagraphFormat.TabStops.Add Position:=CentimetersToPoints(3), Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
    Selection.TypeText Text:=vbTab
    Selection.TypeText "Testje"
    Selection.TypeParagraph
    Selection.ParagraphFormat.TabStops.ClearAll

Een tab kun je overigens ook zo maken:
Code:
    objSelection.TypeText vbTab
Da's een stuk makkelijker te onthouden ;)
 
Bedankt voor jullie reacties.

De positie van de tabs maakt niets uit. Die mag in het hele document hetzelfde blijven.

Ik heb onderstaande code dus geprobeerd, maar de tab afstand is dus hetzelfde als die wat ik bij het andere commando ook kreeg.
Code:
objSelection.TypeText vbTab

Wanneer ik die andere code toevoeg krijg ik een foutmelding
Fout: Instructie wordt verwacht
Complilatiefout Microsoft VBScript

Misschien dat het handig is dat ik het hele script plaats:

Code:
On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")

Set WshShell = CreateObject("WScript.Shell")

strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)


'------------AD LINK INFO-----------------------------------------------------------------------------
strName = objUser.FullName
strTitle = objUser.Description
strCred = objUser.info
strStreet = objUser.StreetAddress
StrPC = objUser.PostalCode
strLocation = objUser.l
strPostCode = objUser.PostalCode
strPhone = objUser.TelephoneNumber
strMobile = objUser.Mobile
strFax = objUser.FacsimileTelephoneNumber
strEmail = objUser.mail
'------------AD LINK INFO------------------------------------------------------------------------------

Set objWord = CreateObject("Word.Application")

Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature

Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
'------------HANDTEKENING PERSONEELS INFO--------------------------------------------------------------
objSelection.Font.Color = RGB(0,0,0)
objSelection.Font.Name = "Arial"
objSelection.Font.Size = 10
objSelection.TypeText "Met vriendelijke groet,"
objSelection.TypeText Chr(11)
objSelection.TypeText Chr(11)
objSelection.TypeText "<bedrijfsnaam>"
objSelection.TypeText Chr(11)
if (strCred) Then objSelection.TypeText strName & ", " & strCred Else objSelection.TypeText strName
objSelection.TypeText Chr(11)
objSelection.TypeText strTitle
objSelection.TypeText Chr(11)
objSelection.TypeText Chr(11)
objSelection.TypeText strStreet
objSelection.TypeText Chr(11)
objSelection.TypeText strPC
objSelection.TypeText " "
objSelection.TypeText strLocation
objSelection.TypeText Chr(11)
objSelection.Font.Color = RGB(217,3,39)
objSelection.TypeText "T"
objSelection.TypeText vbTab
objSelection.Font.Color = RGB(0,0,0)
objSelection.TypeText strPhone
objSelection.TypeText Chr(11)
objSelection.Font.Color = RGB(217,3,39)
if (strMobile) Then objSelection.TypeText "M"
objSelection.TypeText vbTab
objSelection.Font.Color = RGB(0,0,0)
if (strMobile) Then objSelection.TypeText strMobile
if (strMobile) Then objSelection.TypeText Chr(11)
objSelection.Font.Color = RGB(217,3,39)
objSelection.TypeText "E"
objSelection.TypeText vbTab
objSelection.Font.Color = RGB(0,0,0)
Set hyp=objSelection. Hyperlinks. Add (objSelection. Range, "mailto:" & strEmail,,, strEmail)
 hyp. Range. Font. Size="10"
 hyp. Range. Font. Underline = False
 hyp. Range. Font. Color=RGB(0,0,0)
 hyp. Range. Font. Name="Arial"
 'objSelection. Hyperlinks. Add objSelection. range, "mailto:" & strEmail,,, strEmail
objSelection.TypeText Chr(11)
objSelection.Font.Color = RGB(217,3,39)
objSelection.TypeText "I"
objSelection.TypeText Chr(9)
objSelection.Font.Color = RGB(0,0,0)
Set hyp=objSelection. Hyperlinks. Add (objSelection. Range, "<bedrijfsnaam>",,, "www.bedrijf.nl")
 hyp. Range. Font. Size="10"
 hyp. Range. Font. Underline = False
 hyp. Range. Font. Color=RGB(0,0,0)
 hyp. Range. Font. Name="Arial"
 'objSelection. Hyperlinks. Add objSelection. Range, "<bedrijfsnaam>",,, "www.bedrijf.nl")
objSelection.TypeText Chr(11)
objSelection.TypeText Chr(11)
'------------HANDTEKENING PERSONEELS INFO--------------------------------------------------------------
 
Laatst bewerkt:
Weet iemand toevallig ook hoe ik in vbs script met objselection ofzo een afbeelding kan toevoegen met hyperlink en dan de afbeelding kan resizen?
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan