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
496 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Sometimes Outlook might have problems sending a message. There may be various causes- corrupted PST, AV scanner etc. The message, instead of going to the Sent Items folder, sits in the Outbox indefinitely. To remove it you can use a free tool cal…
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now