Consulting

Results 1 to 2 of 2

Thread: VBA + Recordset + Table

  1. #1
    VBAX Regular
    Joined
    Jul 2010
    Posts
    29
    Location

    VBA + Recordset + Table

    Hey,

    I have some code that pulls data from a SQL table into a new email. At the moment the results just appear as multiline text, but I would like them to be put into a table.

    This is what I am using:

    'Create table with 1 row and 3 columns as header, grey the background
    Command.CommandType = adCmdStoredProc
    Command.CommandText = "dbo.ef_sp_GetRemoteDocs"
    Command.Parameters.Append Command.CreateParameter("@BatchId", adGUID, adParamInput, 36, BatchID)
    Set Recordset = Command.Execute
    Do While Not Recordset.EOF
        DocumentID = Mid$(Recordset("DocumentId"), 2, 36)
        FileName = Recordset("FileName")
        FileSize = Recordset("FileSize")
        'Add row for each record, and write data to each cell
        Sel.Hyperlinks.Add Anchor:=Sel.Range, Address:=BaseURL & "/default2.aspx?DocumentID=" & DocumentID, ScreenTip:=FileName, TextToDisplay:=FileName
        Sel.TypeText " (" & Format(FileSize / 1024, "#,###") & " KB)" & vbCrLf
        Recordset.MoveNext
    Loop
    Recordset.Close
    Set Recordset = Nothing
    So it creates a hyperlink and puts the filesize in brackets after.

    I cannot figure out how to programmatically create a table in Outlook!

    Thanks.
    Last edited by ldoodle; 09-07-2017 at 02:13 AM.

  2. #2
    VBAX Regular
    Joined
    Jul 2010
    Posts
    29
    Location
    I've solved this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •