Add web address in table cell with other lines of text (vbscript) RRS feed

  • Question

  • I have a vbscript that creates a signature block. The last piece I need to get working is the addition of the web address within a table cell that already contains lines of text.

    This is a portion of code:

    Const NUMBER_OF_ROWS = 1
    Const NUMBER_OF_COLS = 2
    Const END_OF_STORY = 12

    Set objRange = objSelection.Range
    objDoc.Tables.Add objRange, NUMBER_OF_ROWS, NUMBER_OF_COLS

    Set objTable = objDoc.Tables(1)
    objTable.Columns(1).Width = 70
    objTable.Columns(2).Width = 600
    objTable.Cell(1,2).Range.Text = strAddress
    objTable.Cell(1,2).Range.Text = objTable.Cell(1,2).Range.Text + strCity & ", " & strState & " " & strPostal
    objTable.Cell(1,2).Range.Text = objTable.Cell(1,2).Range.Text + chr(10)
    objTable.Cell(1,2).Range.Text = objTable.Cell(1,2).Range.Text + "www.site.com"
    objTable.Cell(3,1).Range.Text = strConfidential
    objTable.Cell(3,1).Range.Font.Size = 7.5

    objSelection.EndKey END_OF_STORY

    What do I need to do for the website to be in the same cell as the physical address?

    Also, what is the proper blank line character, the chr(10) above gives two blank lines.


    • Moved by Bill_Stewart Monday, April 30, 2018 9:27 PM Unanswerable drive-by question
    Friday, February 23, 2018 9:32 PM

All replies

  • Look in the Gallery for scripts that build a signature block with links and logos.  There ae many the have been written. 

    To add a link you need to define a link object and add it to the range object.

    Here are multiple examples of how to add a hyperlink.

    Hint.  Build and design your signature in Word and place a word field in each place you which to customize.  Use VBScript or PowerShell to open the template and insert the field values.   This can be done in only  a few lines and allows you to alter the template when needed without changing the code.


    • Edited by jrv Friday, February 23, 2018 10:06 PM
    Friday, February 23, 2018 10:03 PM
  • Thanks for the response. To start off this is the first vbscript I have attempted. I did do a search and found examples that I did use. I did see an example that creates the hyperlink but what I am having a hard time figuring out is how to add it to a new line within a cell. I kept getting errors. I will try your idea about doing it in word first and see what I get. Thanks again.
    Friday, February 23, 2018 11:41 PM
  • Here is one with examples of links and many other methods of creating a signature.


    I still say a template is easier and more flexible.  Create a DOTX file and just create a new doc with it then update the fields.


    Friday, February 23, 2018 11:52 PM
  • The signature is being built from AD for the entire firm. I’m looking to put in GPO so users can’t change.
    Saturday, February 24, 2018 1:06 AM
  • That has nothing to do with your question.


    Saturday, February 24, 2018 1:10 AM