Re: MS Word and Barcode font
Can you upload the font here so I can try the code?
1 Attachment(s)
Re: MS Word and Barcode font
ok np's
im sure you know where to put it. :)
Thanks
Re: MS Word and Barcode font
This line is your problem
WordDoc.Tables(1).Cell(1, 1).Select
You are setting the range to be only the first cell of the table.
Re: MS Word and Barcode font
Maybe not. I just tried it. Sorry. Let me work with the code for a minute.
Re: MS Word and Barcode font
Actually it is. Try this code. With it, you will get the bar code in both table cells:
VB Code:
Option Explicit
Dim WordObj As Word.Application
Dim WordDoc As Word.Document
Dim WordRange As Word.Range
Dim WordTable As Word.Table
Dim WordColumn As Word.Column
Dim WordRow As Word.Row
Private Sub Form_Load()
Set WordObj = Nothing
Set WordObj = CreateObject("Word.Application")
Set WordDoc = WordObj.Documents.Add(DocumentType:=wdNewBlankDocument) 'Open the document
Set WordRange = WordDoc.Range(Start:=0, End:=0)
WordObj.Visible = True
With WordRange
'.Font.Name = "Code 128"
'.Font.Size = 16
.InsertParagraphAfter
.InsertParagraphAfter
.SetRange Start:=WordRange.End, End:=WordRange.End
End With
WordDoc.Range(Start:=0, End:=0).Bold = True
Set WordTable = WordDoc.Tables.Add(WordDoc.Paragraphs.Item(2).Range, 1, 2, wdWord9TableBehavior, wdAutoFitFixed)
Set WordRow = WordTable.Rows.Add(BeforeRow:=WordTable.Rows(1))
Selection.GoTo What:=wdGoToTable, Which:=wdGoToNext
WordDoc.Tables(1).Cell(1, 1).Select
WordRange = Selection.Range
' Adds info to cells
With WordObj
' Prints BC1
'.ActiveWindow.Selection.Font.Size = 20
WordRange.Font.Name = "Code 128"
WordRange.Text = "34324324324332"
WordRange.Move Unit:=wdCell
'Set range to cell 1,2
WordDoc.Tables(1).Cell(1, 2).Select
WordRange = Selection.Range
WordRange.Font.Name = "Code 128"
WordRange.Text = "34324324324332"
WordRange.Move Unit:=wdCell
'WordTable.Rows.Add BeforeRow:=WordTable.Rows(1)
End With
WordObj.ActiveDocument.SaveAs "C:\BarCode.doc"
End Sub
Re: MS Word and Barcode font
you know what? for for reason it still pints new times roman.
did print the numbers in barcode font to you?
Re: MS Word and Barcode font
Re: MS Word and Barcode font
ok i got it working but it feels a little unstable to me. this what i did
VB Code:
' Adds info to cells
' Prints BC1
WordObj.ActiveWindow.Selection.Font.Name = "Code 128"
'WordRange.Font.Name = "Code 128"
WordRange.Text = "34324324324332"
WordRange.Move Unit:=wdCell
'Set range to cell 1,2
WordDoc.Tables(1).Cell(1, 2).Select
WordRange = Selection.Range
WordObj.ActiveWindow.Selection.Font.Name = "Code 128"
'WordRange.Font.Name = "Code 128"
WordRange.Text = "34324324324332"
WordRange.Move Unit:=wdCell
'WordTable.Rows.Add BeforeRow:=WordTable.Rows(1)
Re: MS Word and Barcode font
Re: MS Word and Barcode font