Problems changing font size

T

TT

Hello,

I'm trying to copy cells from Excel to Word. This in itself works just fine.
But, I'm having problems in changing font size in different paragraphs. The
settings I apply to the first paragraph apply to all - no matter what.

Here's the code:

------------
Sub TW()

Dim AppWD As Word.Application
Dim DocWD As Word.Document
Dim RangeWD As Word.Range

Set AppWD = CreateObject("Word.Application.11")
AppWD.Visible = True

Set DocWD = AppWD.Documents.Add
With DocWD
Set RangeWD = .Range
Sheets("T").Select
Range("A1:F1").Select
Selection.Copy
With RangeWD
.Font.Name = "Arial"
.Font.Size = 12
.Font.Bold = True
.PasteSpecial DataType:=wdPasteText
'DataType:=wdPasteText, Placement:=wdInLine
End With
Sheets("T").Select
Range("A2:A6").Select
Selection.Copy
With RangeWD
.Font.Name = "Arial"
.Font.Size = 12
.Font.Bold = False
.PasteSpecial DataType:=wdPasteText
End With
End With

End Sub
----------------------

The problem is that font.name, font.size, font.bold I've given to range
A1:F1 applies to A2:A6 as well. How can I get this done? Any ideas?

TIA,

TT
 
O

Ol

TT said:
Hello,

I'm trying to copy cells from Excel to Word. This in itself works just fine.
But, I'm having problems in changing font size in different paragraphs. The
settings I apply to the first paragraph apply to all - no matter what.

Here's the code:

------------
Sub TW()

Dim AppWD As Word.Application
Dim DocWD As Word.Document
Dim RangeWD As Word.Range

Set AppWD = CreateObject("Word.Application.11")
AppWD.Visible = True

Set DocWD = AppWD.Documents.Add
With DocWD
Set RangeWD = .Range
Sheets("T").Select
Range("A1:F1").Select
Selection.Copy
With RangeWD
.Font.Name = "Arial"
.Font.Size = 12
.Font.Bold = True
.PasteSpecial DataType:=wdPasteText
'DataType:=wdPasteText, Placement:=wdInLine
End With
Sheets("T").Select
Range("A2:A6").Select
Selection.Copy
With RangeWD
.Font.Name = "Arial"
.Font.Size = 12
.Font.Bold = False
.PasteSpecial DataType:=wdPasteText
End With
End With

End Sub
----------------------

The problem is that font.name, font.size, font.bold I've given to range
A1:F1 applies to A2:A6 as well. How can I get this done? Any ideas?

TIA,

TT
....
Try to modify that code:

....
With RangeWD
.Font.Name = "Arial"
.Font.Size = 12
.Font.Bold = False
.PasteSpecial DataType:=wdPasteText
End With
End With

to

....
With RangeWD
.Collapse Direction:=wdCollapseEnd
.Font.Name = "Arial"
.Font.Size = 12
.Font.Bold = False
.PasteSpecial DataType:=wdPasteText
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top