PC Review


Reply
Thread Tools Rate Thread

Aligning comments

 
 
=?Utf-8?B?SlQ=?=
Guest
Posts: n/a
 
      20th Jun 2007
My macro gets comments from a legacy system and builds a varaible called
"notes". The comments consist of date, time, user ID and freeform text. I
build a string with spaces between the different fields to try and line them
up because there can be 5, 10, or more comments retrieved for each item.

Once all of the comments have been retrieved from the legacy system, the
"notes" variable is pasted in a cell as an Excel comment. This part works
well; however, when the comments are displayed it looks really ragged. I
would like to try and line up the fields a little better like this:

1/15/07 2:15 PM 12345 Joe said it is okay to pay
10/07/06 3:45 AM 124AB Check should arrive any day

I once used "Courier New" as the text style in a combo box to line up
different fields and it worked really well. I am using the following code to
go back and format all of the comments on a particular sheet once all of the
comments have been pasted in Excel. However, they still aren't lining up
like I want them to.

Sub MyComments()

Dim w As Worksheet
Dim ct As Comment

For Each w In ActiveWorkbook.Worksheets

If w.Name = "My List" Then

For Each cmt In ws.Comments
With ct.Shape.TextFrame.Characters.Font
.Name = "Courier New"
.Size = 9
End With
Next ct
End If
Next w

End Sub

Is it even possible to do what I want? If so any suggestions would be
greatly appreciated. Thanks for the help.........JT

--
JT
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      20th Jun 2007
given the text contains the appropriate number of spaces to line them up and
the comment box is wide enough so you don't get word wrap, using a monospaced
font like courier new should work.

--
Regards,
Tom Ogilvy


"JT" wrote:

> My macro gets comments from a legacy system and builds a varaible called
> "notes". The comments consist of date, time, user ID and freeform text. I
> build a string with spaces between the different fields to try and line them
> up because there can be 5, 10, or more comments retrieved for each item.
>
> Once all of the comments have been retrieved from the legacy system, the
> "notes" variable is pasted in a cell as an Excel comment. This part works
> well; however, when the comments are displayed it looks really ragged. I
> would like to try and line up the fields a little better like this:
>
> 1/15/07 2:15 PM 12345 Joe said it is okay to pay
> 10/07/06 3:45 AM 124AB Check should arrive any day
>
> I once used "Courier New" as the text style in a combo box to line up
> different fields and it worked really well. I am using the following code to
> go back and format all of the comments on a particular sheet once all of the
> comments have been pasted in Excel. However, they still aren't lining up
> like I want them to.
>
> Sub MyComments()
>
> Dim w As Worksheet
> Dim ct As Comment
>
> For Each w In ActiveWorkbook.Worksheets
>
> If w.Name = "My List" Then
>
> For Each cmt In ws.Comments
> With ct.Shape.TextFrame.Characters.Font
> .Name = "Courier New"
> .Size = 9
> End With
> Next ct
> End If
> Next w
>
> End Sub
>
> Is it even possible to do what I want? If so any suggestions would be
> greatly appreciated. Thanks for the help.........JT
>
> --
> JT

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      20th Jun 2007
Format the date/time to ensure the same number of characters:
?format("1/15/07","mm/dd/yy hh:mm AM/PM")

And assuming the userID is a constant length, the fixed-width font should
line up.
You would still need to ensure the text frame is wide enough to display all
characters. You can get the display width from Len(Longest Line) * Scale
Factor, which you can get with a little trial and error.

NickHK

"JT" <(E-Mail Removed)> 撰寫於郵件新聞:378AAB81-4D85-41E2-9BE8-(E-Mail Removed)...
> My macro gets comments from a legacy system and builds a varaible called
> "notes". The comments consist of date, time, user ID and freeform text.
> I
> build a string with spaces between the different fields to try and line
> them
> up because there can be 5, 10, or more comments retrieved for each item.
>
> Once all of the comments have been retrieved from the legacy system, the
> "notes" variable is pasted in a cell as an Excel comment. This part works
> well; however, when the comments are displayed it looks really ragged. I
> would like to try and line up the fields a little better like this:
>
> 1/15/07 2:15 PM 12345 Joe said it is okay to pay
> 10/07/06 3:45 AM 124AB Check should arrive any day
>
> I once used "Courier New" as the text style in a combo box to line up
> different fields and it worked really well. I am using the following code
> to
> go back and format all of the comments on a particular sheet once all of
> the
> comments have been pasted in Excel. However, they still aren't lining up
> like I want them to.
>
> Sub MyComments()
>
> Dim w As Worksheet
> Dim ct As Comment
>
> For Each w In ActiveWorkbook.Worksheets
>
> If w.Name = "My List" Then
>
> For Each cmt In ws.Comments
> With ct.Shape.TextFrame.Characters.Font
> .Name = "Courier New"
> .Size = 9
> End With
> Next ct
> End If
> Next w
>
> End Sub
>
> Is it even possible to do what I want? If so any suggestions would be
> greatly appreciated. Thanks for the help.........JT
>
> --
> JT



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      20th Jun 2007
I haven't followed the thread, only this -

> You would still need to ensure the text frame is wide enough to display

all
> characters.


Dim cm As Comment, s$
Set cm = ActiveSheet.Comments(1)
s = "This is line 1" & vbLf & _
"Line 2 is a much longer line" & vbLf & _
"Line 3"

cm.Text Text:=s
cm.Shape.TextFrame.AutoSize = True
msgbox cm.Shape.Width

If all comments should be same width when done, trap the largest width,
re-set each AutoSize = false, and size all to largest.

Regards,
Peter T

"NickHK" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Format the date/time to ensure the same number of characters:
> ?format("1/15/07","mm/dd/yy hh:mm AM/PM")
>
> And assuming the userID is a constant length, the fixed-width font should
> line up.
> You would still need to ensure the text frame is wide enough to display

all
> characters. You can get the display width from Len(Longest Line) * Scale
> Factor, which you can get with a little trial and error.
>
> NickHK
>
> "JT" <(E-Mail Removed)>

撰寫於郵件新聞:378AAB81-4D85-41E2-9BE8-(E-Mail Removed)...
> > My macro gets comments from a legacy system and builds a varaible called
> > "notes". The comments consist of date, time, user ID and freeform text.
> > I
> > build a string with spaces between the different fields to try and line
> > them
> > up because there can be 5, 10, or more comments retrieved for each item.
> >
> > Once all of the comments have been retrieved from the legacy system, the
> > "notes" variable is pasted in a cell as an Excel comment. This part

works
> > well; however, when the comments are displayed it looks really ragged.

I
> > would like to try and line up the fields a little better like this:
> >
> > 1/15/07 2:15 PM 12345 Joe said it is okay to pay
> > 10/07/06 3:45 AM 124AB Check should arrive any day
> >
> > I once used "Courier New" as the text style in a combo box to line up
> > different fields and it worked really well. I am using the following

code
> > to
> > go back and format all of the comments on a particular sheet once all of
> > the
> > comments have been pasted in Excel. However, they still aren't lining

up
> > like I want them to.
> >
> > Sub MyComments()
> >
> > Dim w As Worksheet
> > Dim ct As Comment
> >
> > For Each w In ActiveWorkbook.Worksheets
> >
> > If w.Name = "My List" Then
> >
> > For Each cmt In ws.Comments
> > With ct.Shape.TextFrame.Characters.Font
> > .Name = "Courier New"
> > .Size = 9
> > End With
> > Next ct
> > End If
> > Next w
> >
> > End Sub
> >
> > Is it even possible to do what I want? If so any suggestions would be
> > greatly appreciated. Thanks for the help.........JT
> >
> > --
> > JT

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel 2000 how to format the comments font all comments Delquestion Microsoft Excel Misc 1 8th Oct 2009 02:19 PM
Merge Comments / Wrap comments / Concatonate Comments Gary Microsoft Access Queries 4 15th Apr 2009 03:46 PM
in excel useing comments how do you add clip art to comments? =?Utf-8?B?ZGhvdXNl?= Microsoft Excel New Users 2 18th Jul 2007 08:14 AM
Aligning decimal numers to the centre of the cell and aligning dec =?Utf-8?B?UmFtZXNoIEJhYnU=?= Microsoft Excel Misc 1 1st Jul 2006 10:33 PM
Comments record length cannot exceed 4000 in Comments of BCM, Outlook 2003 Chris Street Microsoft Outlook Discussion 1 20th Apr 2004 03:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:44 AM.