Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
Sunil Pradhan Sunil Pradhan is offline
external usenet poster
 
Posts: 5
Default Formating first line of every cells in first column of word table.

Trying to write a macro which can convert first line of every cells in first
column of word table. pls help
  #2   Report Post  
Posted to microsoft.public.word.tables
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Formating first line of every cells in first column of word table.

What do you mean by 'format'?
What do you mean by 'convert'
What do you mean by 'first line'?

The following macro will locate the content of the first cell of each row in
turn and assign it to a range variable. You can then process that range to
do what you wish.

Dim oRng As Range
With ActiveDocument.Tables(1)
For i = 1 To .Rows.Count
Set oRng = .Rows(i).Cells(1).Range
oRng.End = oRng.End - 1
'orng is the content of the first cell of the row
Next i
End With


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Sunil Pradhan wrote:
Trying to write a macro which can convert first line of every cells
in first column of word table. pls help



  #3   Report Post  
Posted to microsoft.public.word.tables
Sunil Pradhan Sunil Pradhan is offline
external usenet poster
 
Posts: 5
Default Formating first line of every cells in first column of word ta

I want to have first line of each cells in first column of table in different
format (font type, size) etc. each cells have 1st line as heading and other
lines as body. I can send you an sample if i get your email address. I am
trying to write macro in word for the first time & unable to understand. I
am used to in writing macros in excel.
thx


"Graham Mayor" wrote:

What do you mean by 'format'?
What do you mean by 'convert'
What do you mean by 'first line'?

The following macro will locate the content of the first cell of each row in
turn and assign it to a range variable. You can then process that range to
do what you wish.

Dim oRng As Range
With ActiveDocument.Tables(1)
For i = 1 To .Rows.Count
Set oRng = .Rows(i).Cells(1).Range
oRng.End = oRng.End - 1
'orng is the content of the first cell of the row
Next i
End With


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Sunil Pradhan wrote:
Trying to write a macro which can convert first line of every cells
in first column of word table. pls help




  #4   Report Post  
Posted to microsoft.public.word.tables
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Formating first line of every cells in first column of word ta

I would suggest that you use separate rows for the headings and apply
different paragraph styles to the heading and body rows.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"Sunil Pradhan" wrote in message
...
I want to have first line of each cells in first column of table in
different
format (font type, size) etc. each cells have 1st line as heading and
other
lines as body. I can send you an sample if i get your email address. I
am
trying to write macro in word for the first time & unable to understand.
I
am used to in writing macros in excel.
thx


"Graham Mayor" wrote:

What do you mean by 'format'?
What do you mean by 'convert'
What do you mean by 'first line'?

The following macro will locate the content of the first cell of each row
in
turn and assign it to a range variable. You can then process that range
to
do what you wish.

Dim oRng As Range
With ActiveDocument.Tables(1)
For i = 1 To .Rows.Count
Set oRng = .Rows(i).Cells(1).Range
oRng.End = oRng.End - 1
'orng is the content of the first cell of the row
Next i
End With


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Sunil Pradhan wrote:
Trying to write a macro which can convert first line of every cells
in first column of word table. pls help






  #5   Report Post  
Posted to microsoft.public.word.tables
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Formating first line of every cells in first column of word ta

You didn't answer my question 'What do you mean by 'first line'.

If the first line ends with a paragraph mark i.e. enter was pressed, then
the first line is paragraph(1) of the range, so

Dim oRng As Range
With ActiveDocument.Tables(1)
For i = 1 To .Rows.Count
Set oRng = .Rows(i).Cells(1).Range
'orng is the content of the first cell of the row
oRng.End = oRng.End - 1 'exclude the cell end marker
With oRng.Paragraphs(1).Range 'work with the first paragraph
'and apply formatting to it
.Font.name = "Arial"
.Font.Size = "14"
.Font.Bold = True
End With
Next i

However if the line is wrapped naturally by the confines of the cell, it
becomes altogether more complicated, for if you apply formatting to what was
the first line, the formatting will almost certainly affect the text flow,
thus some of the first line will now wrap to the second or the line will be
shortened and some of what was the second line will move up to the first.
How would you wish to handle that?

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Sunil Pradhan wrote:
I want to have first line of each cells in first column of table in
different format (font type, size) etc. each cells have 1st line as
heading and other lines as body. I can send you an sample if i get
your email address. I am trying to write macro in word for the first
time & unable to understand. I am used to in writing macros in excel.
thx


"Graham Mayor" wrote:

What do you mean by 'format'?
What do you mean by 'convert'
What do you mean by 'first line'?

The following macro will locate the content of the first cell of
each row in turn and assign it to a range variable. You can then
process that range to do what you wish.

Dim oRng As Range
With ActiveDocument.Tables(1)
For i = 1 To .Rows.Count
Set oRng = .Rows(i).Cells(1).Range
oRng.End = oRng.End - 1
'orng is the content of the first cell of the row
Next i
End With


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Sunil Pradhan wrote:
Trying to write a macro which can convert first line of every cells
in first column of word table. pls help





  #6   Report Post  
Posted to microsoft.public.word.tables
Sunil Pradhan Sunil Pradhan is offline
external usenet poster
 
Posts: 5
Default Formating first line of every cells in first column of word ta

Yes Graham, it did work for me. I have used the exact codes you have posted
& it worked. Apologize for not replying correctly. The first line was a
paragraph completed by enter key.

Thank you again, Sunil Pradhan.

"Graham Mayor" wrote:

You didn't answer my question 'What do you mean by 'first line'.

If the first line ends with a paragraph mark i.e. enter was pressed, then
the first line is paragraph(1) of the range, so

Dim oRng As Range
With ActiveDocument.Tables(1)
For i = 1 To .Rows.Count
Set oRng = .Rows(i).Cells(1).Range
'orng is the content of the first cell of the row
oRng.End = oRng.End - 1 'exclude the cell end marker
With oRng.Paragraphs(1).Range 'work with the first paragraph
'and apply formatting to it
.Font.name = "Arial"
.Font.Size = "14"
.Font.Bold = True
End With
Next i

However if the line is wrapped naturally by the confines of the cell, it
becomes altogether more complicated, for if you apply formatting to what was
the first line, the formatting will almost certainly affect the text flow,
thus some of the first line will now wrap to the second or the line will be
shortened and some of what was the second line will move up to the first.
How would you wish to handle that?

--

Graham Mayor - Word MVP

My web site
www.gmayor.com
Word MVP web site http://word.mvps.org



Sunil Pradhan wrote:
I want to have first line of each cells in first column of table in
different format (font type, size) etc. each cells have 1st line as
heading and other lines as body. I can send you an sample if i get
your email address. I am trying to write macro in word for the first
time & unable to understand. I am used to in writing macros in excel.
thx


"Graham Mayor" wrote:

What do you mean by 'format'?
What do you mean by 'convert'
What do you mean by 'first line'?

The following macro will locate the content of the first cell of
each row in turn and assign it to a range variable. You can then
process that range to do what you wish.

Dim oRng As Range
With ActiveDocument.Tables(1)
For i = 1 To .Rows.Count
Set oRng = .Rows(i).Cells(1).Range
oRng.End = oRng.End - 1
'orng is the content of the first cell of the row
Next i
End With


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Sunil Pradhan wrote:
Trying to write a macro which can convert first line of every cells
in first column of word table. pls help




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I Insert a column into a table that contains split cells Kate Vaughn Tables 1 August 9th 06 05:48 AM
Word Table: When I select a Column, some rows have 2 cells selecte DonD Microsoft Word Help 3 June 15th 06 08:40 AM
In Word - How do I add a column in a table with merged cells? DaveK Tables 2 June 8th 06 11:13 PM
Formating table Cells Jaz Tables 1 May 1st 06 05:14 PM
Count non-blank cells in a table column Bradley C. Hammerstrom New Users 4 December 14th 04 02:47 AM


All times are GMT +1. The time now is 02:02 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"