This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I have a .vbs script that using obj.write creates an html file. Then it saves 3 versions of the file (.html, .rtf, .txt) for an outlook signature. Then it opens the html file in word and saves it as the signature. The problem is, that the file I write has proper spacing. After it opens up in word and saves it as the signature it screws with the spacing.
I am not great with vbs scripting, just enough to modify others script or kind of figure out what its doing. I tried "objSelection.ParagraphFormat.LineSpacing = 12" on the line after "Set objSelection = objDoc.Range()" but that did nothing (I even tried setting it to an absurdly large numer just to make sure).
I want to say the problem is in the last 5 lines of code where it saves the file as the signature?
Any help? Code below
'Convert the HTML Version to RTF and Plain Text:
Dim objDoc, objWord, objEmailOptions, objSignatureObject, objSignatureEntries, objSelection
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
If objFSO.FileExists(strLocalSignatureFolder & "\" & strSignatureName & ".html") Then
objWord.Documents.Open strLocalSignatureFolder & "\" & strSignatureName & ".html"
Set objDoc = objWord.ActiveDocument
objDoc.SaveAs strLocalSignatureFolder & "\" & strSignatureName & ".rtf", wdFormatRTF
objDoc.SaveAs strLocalSignatureFolder & "\" & strSignatureName & ".txt", wdFormatTextLineBreaks
objDoc.SaveAs strTextSignatureFolder & "\" & strTestFileName & ".txt", wdFormatTextLineBreaks
'objDoc.SaveAs strLocalSignatureFolder & "\" & strSignatureName & ".2.html", wdFormatHTML
objDoc.Close
objWord.Quit
End If
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(strLocalSignatureFolder & "\" & strSignatureName & ".html",,True)
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
Set objSelection = objDoc.Range()
objSignatureEntries.Add "Full Signature", objSelection
objSignatureObject.NewMessageSignature = "Full Signature"
objDoc.Saved = True
objWord.Quit
TLDR; I need to use vbs to open a html file, that the script creates, in word and save it as the outlook signature (with correct line spacing).
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/vbscript/co...