Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Format word created from Excel VBA

Hello,
I have the following code to create word from excel VBA. I cant find a
way to formatsome of the text with BOLD or font size. Any help will be
great!

Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = False
Set wrdDoc = wrdApp.Documents.Add ' create a new document

With wrdDoc

.Content.InsertAfter "Date " & Me.DTPicker1.Value & vbCr & vbCr

' How to format font ????

..Content.InsertAfter vbTab & "^B Return Material Authorization" & vbCr
& vbCr
.SaveAs Range("Info!G2").Text & "\RMA report for " &
Me.TextBox17_PartNumber & ".doc"
.Close ' close the document
End With

wrdApp.Quit ' close the Word application

Set wrdDoc = Nothing
Set wrdApp = Nothing


Thanls!!!

Eran

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Format word created from Excel VBA

You did not specify which font so here is a simple example setting the font
to bold. I changed the create object to just instantiating a new instance of
word since you referenced the Word library anyway...

Sub Test()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document

Set wrdApp = New Word.Application
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add ' create a new document

With wrdDoc
.Characters(1).Font.Bold = wdToggle
.Content.InsertAfter "Date " & vbCr & vbCr

' How to format font ????

.Close ' close the document
End With

wrdApp.Quit ' close the Word application

Set wrdDoc = Nothing
Set wrdApp = Nothing

End Sub
--
HTH...

Jim Thomlinson


" wrote:

Hello,
I have the following code to create word from excel VBA. I cant find a
way to formatsome of the text with BOLD or font size. Any help will be
great!

Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = False
Set wrdDoc = wrdApp.Documents.Add ' create a new document

With wrdDoc

.Content.InsertAfter "Date " & Me.DTPicker1.Value & vbCr & vbCr

' How to format font ????

..Content.InsertAfter vbTab & "^B Return Material Authorization" & vbCr
& vbCr
.SaveAs Range("Info!G2").Text & "\RMA report for " &
Me.TextBox17_PartNumber & ".doc"
.Close ' close the document
End With

wrdApp.Quit ' close the Word application

Set wrdDoc = Nothing
Set wrdApp = Nothing


Thanls!!!

Eran


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to "crop" charts created in Excel and moved to Word Jim Charts and Charting in Excel 4 December 7th 09 01:57 PM
how do i format a textbox on a userform created in excel Bert New Users to Excel 1 May 5th 08 11:46 PM
SOS!!! Excel 2007 - Pivot tables created in 2003 format Tina Excel Discussion (Misc queries) 0 August 20th 07 11:20 PM
Printing Problem in Word Document Created from Excel VBA Jim Skrydlak[_2_] Excel Programming 2 January 30th 06 05:56 PM
Excel-created Word instance hanging on thru Outlook? Ed Excel Programming 0 November 3rd 05 03:31 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"