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
534 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

691 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