Solved

Can't seem create the last column of the Grid by itself in the vbAccelerator Grid for Outlook 2007 VBA script

Posted on 2012-04-09
10
522 Views
Last Modified: 2012-08-13
We are working in Outlook 2007 VBA using a Grid from vbAccelerator.com

For some strange reason, we can't seem to get the last column (in the example below is "Comments") to display without adding an additional line (see line "blank").  If we don't add the "blank" line, the "Comments" doesn't appear (see pic); only if we include the "blank" line.

How can we add a column correctly to the Grid?
0
Comment
Question by:rayluvs
  • 5
  • 4
10 Comments
 

Author Comment

by:rayluvs
ID: 37824783
oops, the forgot script and pic:

Private Sub AddColumns()
  Dim nCol As Integer
  With UserForm1.gridItemsFound
    .Redraw = False
    'This setups the Header of the Grid
    'first columns header will be adjusted while code is running
    .AddColumn vKey:="Date", sheader:="Date", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=60
    .AddColumn vKey:="Project", sheader:="Project", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=300
    .AddColumn vKey:="Subject", sheader:="Email", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=300
    .AddColumn vKey:="Task", sheader:="Task", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=200
    .AddColumn vKey:="Type", sheader:="Type", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=100
    .AddColumn vKey:="Dept.", sheader:="Dept", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=100
    .AddColumn vKey:="Comments", sheader:="Comments", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=100
    .AddColumn vKey:="blank", sheader:="blank", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=10
    .Redraw = True
  End With
End Sub

Open in new window


LastColumnProblem
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 37825969
Chris here

Yes, I noticed that too at my end.

The "quick" workaround you have performed is the correct one.

I will investigate the code I have already supplied to you and get back to you.

Cheers
Chris
0
 

Author Comment

by:rayluvs
ID: 37825982
Thanx
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 15

Accepted Solution

by:
eemit earned 500 total points
ID: 37826169
Hi Ramante,

1)
According to vbAccelerator - SGrid 2.0 Documentation:
The row-text column is used to display text and/or icons which stretch across multiple columns
in the grid. The Row-Text column renders below the standard columns. If you are using one,
the row-text column must always be the last column in the grid.

With Code you posted you schould get Error:
"Cannot add a second row text column to the grid".

change:
bRowTextColumn:=True
in each Column to:
bRowTextColumn:=False

2)
If you nead a Row-Text column, add one after Column "Comments" and set it's bRowTextColumn:=True
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 37826176
Ramante is not using version 2 of the Grid yet, so that error does not occur.
(We will move onto Grid2 later).

I am the original coder for Ramada and I am currently investigating the reason.

Stand By....
0
 

Author Comment

by:rayluvs
ID: 37826194
Correct!  Worked

Thank you!
0
 

Author Comment

by:rayluvs
ID: 37826196
Didn't read your last entry.  Ok with Grid2 later on
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 37826242
Ok, Ramnante, that slipped by me :-)

I have amended my code at this end too so I can work on your other questions now.

Note that I have seperated the "Column Indexing" now into a seperate subroutine. This will make calls to that subroutine easier should we need it.

Have you added the "ID" column in yet (hidden) ?

It is needed to allow the user interaction with the email item directly from your Grid.


Cheers
Chris

Private Sub AddColumns()
  Dim nCol As Integer
  Dim OCols As Columns
  Dim ocol As Column
  With UserForm1.gridItemsFound
    .Redraw = False
    'first columns header will be adjusted while code is running
    .AddColumn vKey:="SearchType", sheader:="", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=False, lcolumnwidth:=400
    .AddColumn vKey:="Task", sheader:="Task", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=False, lcolumnwidth:=10
    .AddColumn vKey:="Type", sheader:="Type", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=False, lcolumnwidth:=10
    .AddColumn vKey:="From", sheader:="From", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=False, lcolumnwidth:=10
    .AddColumn vKey:="To", sheader:="To", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=False, lcolumnwidth:=10
    .AddColumn vKey:="Email", sheader:="Email", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=False, lcolumnwidth:=10
    .AddColumn vKey:="ID", sheader:="ID", bRowTextColumn:=False, lcolumnwidth:=20, bVisible:=False
    .ColumnOrder("SearchType") = GetSetting(Application.Name, "Setup", "ColOrder" + CStr(nCol), 1)
    .ColumnWidth("SearchType") = GetSetting(Application.Name, "Setup", "ColWidth" + CStr(nCol), 400)

    For nCol = 2 To .Columns
      .ColumnOrder(nCol) = GetSetting(Application.Name, "Setup", "ColOrder" + CStr(nCol), nCol)
      .ColumnWidth(nCol) = GetSetting(Application.Name, "Setup", "ColWidth" + CStr(nCol), 100)
    Next
    SetColIndexes

    .Redraw = True
    
  End With

End Sub

Private Sub SetColIndexes()
  ReDim lColIndex(UserForm1.gridItemsFound.Columns)
  On Error Resume Next ' Because some columns may have been deleted through the UI
  With UserForm1.gridItemsFound
    lColIndex(i_PROJECT) = .ColumnIndex("SearchType")
    lColIndex(i_SUBJECT) = .ColumnIndex("SearchType")
    lColIndex(i_TASKS) = .ColumnIndex("Tasks")
    lColIndex(i_TYPE) = .ColumnIndex("Type")
    lColIndex(i_FROM) = .ColumnIndex("From")
    lColIndex(i_TO) = .ColumnIndex("To")
    lColIndex(i_EMAIL) = .ColumnIndex("Email")
  End With
  On Error GoTo 0
End Sub

Open in new window

0
 

Author Comment

by:rayluvs
ID: 37826298
Please explain the additional lines in the routine AddColumns():

    For nCol = 2 To .Columns
      .ColumnOrder(nCol) = GetSetting(Application.Name, "Setup", "ColOrder" + CStr(nCol), nCol)
      .ColumnWidth(nCol) = GetSetting(Application.Name, "Setup", "ColWidth" + CStr(nCol), 100)
    Next

Open in new window

0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 38047163
Oops!

You last question slipped by me and I have only just noticed it!

What the function "GetSetting" does is pick up from the Registry the stored "Column Orders" amd Column Widths" for each column which should be saved in your code somewhere (usually in the "Unload" method of a form or in the closing code just as your VBA code finished.

The code should like something like this:

      With UserForm1.gridItemsFound
         For nCol = 2 To .Columns
             SaveSetting  Application.Name, "Setup",  _
                                 "ColOrder" + CStr(nCol), .ColumnOrder(nCol)
             SaveSetting  Application.Name, "Setup", _
                                 "ColWidth" + CStr(nCol), .ColumnWidth(nCol)
         Next
      End With

Open in new window


You may now close this question if all is OK.

Cheers
Chris
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Enabling exchange 2013 read receipt 7 21
Everything left of comma in excel 4 44
Outlook will send but not receive 11 46
exchange 2007, outlook 3 19
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question