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
How to change font in MS Word bookmark
Page 1 of 14 Replies - 1199 Views - Last Post: 01 December 2012 - 01:00 PM
Replies To: How to change font in MS Word bookmark
#2
Re: How to change font in MS Word bookmark
Posted 22 November 2012 - 11:26 AM
Don't know that one offhand, sorry. Are you getting errors or does it just not work?
Please read the watermarks in the reply box and use code tags as explained there.
Please read the watermarks in the reply box and use code tags as explained there.
#3
Re: How to change font in MS Word bookmark
Posted 23 November 2012 - 12:44 AM
Hi thanks for your reply,
No I don't get any errors it just doesn't work.
I will use code tags next time. Thank you.
No I don't get any errors it just doesn't work.
I will use code tags next time. Thank you.
#4
Re: How to change font in MS Word bookmark
Posted 23 November 2012 - 01:38 AM
Hi Bob,
I got it. Searched Google and found a site containing Word VBA code samples for Newbies.
It is very when you know how to.
Thank you for your effort to help out with VB.
Here is a link to the site : http://www.thezcorp....odeSamples.aspx
I got it. Searched Google and found a site containing Word VBA code samples for Newbies.
It is very when you know how to.
WordDoc.Bookmarks("Test").Select
Selection.Font.size = 36
Selection.Font.Name = "Segoe UI"
Selection.Font.ColorIndex = wdRed
Thank you for your effort to help out with VB.
Here is a link to the site : http://www.thezcorp....odeSamples.aspx
#5
Re: How to change font in MS Word bookmark
Posted 01 December 2012 - 01:00 PM
Thanks for posting your solution.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|