Kshirsagar Posted April 8, 2010 Share Posted April 8, 2010 Currently, I can extract all text from Excel and create same in AutoCAD by using addMText function. Before saving autoCAD file I can see expected result, like if 1 cell contains font Tahoma then Autocad file will have font Tahoma too. but when I save & close autoCAD file, I can see font changes to ARIAL. Can any one help me in this situation. Code has pasted below. Thank you in advance. myText = xlSheet.Cells(iRow, iCol) xDist = xDist + xlSheet.Cells(iRow, iCol).Width InsertPoint(0) = spX 'xDist InsertPoint(1) = -spY 'yDist InsertPoint(2) = 0 Set Styobj = acadApp.ActiveDocument.TextStyles.Item("Standard") 'Add("M_Font1") Typeface = CStr(xlSheet.Cells(iRow, iCol).Font.Name) 'E.g typeface could be Tahoma, Arial If xlSheet.Cells(iRow, iCol).Font.FontStyle = "Bold" Then bold = True Else bold = False End If If xlSheet.Cells(iRow, iCol).Font.Italic = "True" Then Italic = True Else Italic = False End If Charset = 1 PitchandFamily = 1 Or 16 Styobj.SetFont Typeface, bold, Italic, Charset, PitchandFamily acadApp.ActiveDocument.ActiveTextStyle = Styobj Set mText = doc.ModelSpace.AddMText(InsertPoint, xlSheet.Cells(iRow, iCol).Width + 1, myText) mText.Height = 4 mText.Color = acGreen mText.Update Set Styobj = Nothing Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 8, 2010 Share Posted April 8, 2010 I notice you are modifying the TextStyle font to match that retrieved from the Excel file - I've had trouble with this method in the past, certainly as far as changing bold/italic settings - they look ok, but don't stay. How about approaching it using MText formatting codes? Or is this not desirable? Lee Quote Link to comment Share on other sites More sharing options...
Kshirsagar Posted April 8, 2010 Author Share Posted April 8, 2010 Hi Lee, Above program works, I can see expected results BUT When I open AutoCAD file again all texts font get replace with default Arial. I dont know why. any Idea? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 8, 2010 Share Posted April 8, 2010 As I remarked: I've had trouble with this method in the past, certainly as far as changing bold/italic settings - they look ok, but don't stay. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.