Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


How to change font in MS Word using VB6


How to change font in MS Word using VB6

Author
Message
henrikl2000
henrikl2000
Supreme Being
Supreme Being (289 reputation)Supreme Being (289 reputation)Supreme Being (289 reputation)Supreme Being (289 reputation)Supreme Being (289 reputation)Supreme Being (289 reputation)Supreme Being (289 reputation)Supreme Being (289 reputation)Supreme Being (289 reputation)

Group: Forum Members
Posts: 1, Visits: 8

I am using VB6 to create an application that uses MS Word 2010 to print labels. My question is how do I change the font size, name etc. in a Word Bookmark that is inside a textfield (shape). I can change the font in a plain document but not if the bookmark is inside a textfield.

 

I have been trying the following code:

 

If doc.Bookmarks.Exists("Barcode1") Then

    If doc.Bookmarks("Barcode1").Range.Font.Size = MultiSelection Then

        ' the range of the bookmark consists of runs with different font sizes

        doc.Bookmarks("Barcode1").Range.Font.Size = 20

    Else

        doc.Bookmarks("Barcode1").Range.Font.Size _

            = doc.Bookmarks("Barcode1").Range.Font.Size + 4

    End If

End If

 

And this too:

 

    Dim WordObj As Word.Application

    Set WordObj = CreateObject("Word.Application")

 

    Dim objWord As Word.Document

    Set objWord = WordObj.Documents.Open(FileName:=App.Path & "\LabelLayout\test.docx") '" & SelectedLabelLayout & ".docx")  '"C:\Users\Henrik\Documents\L7159test.docx") 'Test.docx")

   

    WordObj.Visible = True

    With objWord.Bookmarks

        .Item("Barcode1").Range.Text = txtEtiket(0).Text 'txtName

        .Item("Barcode1").Range.FormattedText.Font.Name = "Segoe UI" 'Font.Color = wdColorRed

        .Item("Barcode1").Range.FormattedText.Font.Size = "16"

  End with

zack
zack
Forum God
Forum God (13K reputation)Forum God (13K reputation)Forum God (13K reputation)Forum God (13K reputation)Forum God (13K reputation)Forum God (13K reputation)Forum God (13K reputation)Forum God (13K reputation)Forum God (13K reputation)

Group: Forum Members
Posts: 102, Visits: 110
Have you tried changing the default settings that are used when you insert a shape or text box in your Word document?

Look at this and scroll down to the Word section.



http://office.microsoft.com/en-us/word-help/set-new-formatting-defaults-for-a-shape-or-text-box-HA010244963.aspx#BMwo>
Edited
11/22/2012 by zack
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search