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
505 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
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…
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: …

911 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

15 Experts available now in Live!

Get 1:1 Help Now