Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

How to set font while writing to MS word

  Asked By: Ludwig    Date: Nov 04    Category: MS Office    Views: 746
  

I am writing an Excel macro which inset test in MS Word if a particular
cell has the value 'ok'.
While writing by default font in msword is courier new but i want that
to insert in someother font type and fort size.

how to set font type and font size while writing to ms word from excel
macro.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Devin Ross     Answered On: Nov 04

You may try:

dim WD As WOrd.application
set wd = new word.application
wd.documents.open ("document path")
wd.visible = true
..
..
..
If Cells(i,1)="OK" then
WD.selection.font.name = "target font"
WD.Selection.Font.Size = 10
End If

 
Answer #2    Answered By: Aran Boonliang     Answered On: Nov 04

i am not able to print to doc by using your code,
i have tried the below way but changes are reflecting in excel  instead of
word.....
Kindly check the below code and suggest
'***********************************************************************

Sub king()
fileNum = FreeFile()
cValStr = "Test case is passing"
Open "C:\Documents and Settings\naseemahmed_shaik\Desktop\try.doc" For Output
As fileNum
With Selection.Font
.Name = "Trebuchet MS"
..Size = 12
End With

Print #fileNum, cValStr '************************** here i want cValStr to be
printed in "Trebuchet MS"***************
Close #fileNum
Close #try
End Sub

 
Didn't find what you were looking for? Find more on How to set font while writing to MS word Or get search suggestion and latest updates.




Tagged: