Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Some .doc files don't contain a text style I want to use.
The code: GetOrCreateTextStyle I found somewhere uses a variable called "bgfilename" which I assume points to a generic font template file.
Does anyone know what file path this variable might refer to?
Public Function GetOrCreateTextStyle(ByVal stylename As String, ByVal fontfilename As String, ByVal bgfilename As String, ByVal textheight As Double, ByRef trans As Transaction) As ObjectId
Dim id As ObjectId = GetTextStyle(stylename, trans)
If id = Nothing Then
id = CreateTextStyle(stylename, fontfilename, bgfilename, textheight, trans)
End If
Return id
End Function
Public Function GetTextStyle(ByVal stylename As String, ByRef trans As Transaction) As ObjectId
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Return GetNonErasedTableRecordId(db.TextStyleTableId, stylename, trans)
End Function
Public Function GetNonErasedTableRecordId(ByVal TableId As ObjectId, ByVal Name As String, ByRef trans As Transaction) As ObjectId
Dim id As ObjectId = Nothing
Dim table As SymbolTable = DirectCast(trans.GetObject(TableId, OpenMode.ForRead), SymbolTable)
If table.Has(Name) Then
id = table(Name)
If Not id.IsErased Then
Return id
End If
For Each recId As ObjectId In table
If Not recId.IsErased Then
Dim rec As SymbolTableRecord = DirectCast(trans.GetObject(recId, OpenMode.ForRead), SymbolTableRecord)
If String.Compare(rec.Name, Name, True) = 0 Then
Return recId
End If
End If
Next
End If
Return id
End Function
Public Function CreateTextStyle(ByVal stylename As String, ByVal filename As String, ByVal bgfilename As String, ByVal textheight As Double, ByRef trans As Transaction) As ObjectId
Dim id As ObjectId = Nothing
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Try
Dim tst As TextStyleTable = DirectCast(trans.GetObject(db.TextStyleTableId, OpenMode.ForRead, False), TextStyleTable)
Using ts As New TextStyleTableRecord()
ts.Name = stylename
ts.FileName = filename
If bgfilename <> String.Empty Then
ts.BigFontFileName = bgfilename
End If
ts.TextSize = textheight
ts.XScale = 1.0
tst.UpgradeOpen()
tst.Add(ts)
trans.AddNewlyCreatedDBObject(ts, True)
id = ts.ObjectId
End Using
Catch ex As Exception
MsgBox(Reflection.MethodBase.GetCurrentMethod.Name() + " Exception: " + ex.Message)
End Try
Return id
End Function
Solved! Go to Solution.
|