set print fonts in visual basic RRS feed

  • Question

  • i am using visual I have printed before and was able to set my fonts with a dim statement

    dim headerfont as new font("arial', 14 , FontStyle.Bold)

    this worked fine in the past but I am importing Excel and that is upsetting the font command.  how do I over ride or what do I need to change to be able to set up my headerfont???

    thanks Chris

    Tuesday, July 10, 2018 6:45 PM

All replies

  • Hi Chris,

    I guess the first question would be - how are you performing the printing, or is this about cell formatting?

    Where the text to print comes from, whether it be from a user typing, opening a text file, or imported (consumed from a save file) from Excel, once you have a string of text all that matters is the method you use to print it.

    Or perhaps you mean that you are automating an instance of Excel (importing the Excel interop assembly) and having trouble setting a font style for text that you inserted into a spreadsheet.  If that were the case, it wouldn't be about printing but rather cell formatting in Excel.

    Can you please explain what you are trying to do a little further?

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Tuesday, July 10, 2018 8:54 PM
  • Hi w1knight

    Have you tried setting the font like this?Set the first row of cell fonts.

    Dim myExcel As Excel.Application = New Excel.Application()
        Dim workbookData As Excel.Workbook = myExcel.Application.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet)
        Dim xlSheet As Excel.Worksheet = CType(workbookData.Worksheets(1), Worksheet)
        xlSheet.Rows(1).Font.Name = "arial"
        xlSheet.Rows(1).Font.Bold =True

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, July 11, 2018 6:29 AM