![]() |
Unable to format font after creating sheet
I have built that creates a worksheet and everything works perfect except
when I try to select the cells and change the font to Microsoft San Serif-8. I get the error message "The Remote Server Machine does not exist or is unavailable" My code is as follows: xlSheet.Range("A1").Select xlSheet.Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select With Selection.Font .NAME = "Microsoft Sans Serif" .Size = 8 End With xlApp.Application.Visible = True Any suggestions are greatly appreciated! |
Unable to format font after creating sheet
xlSheet is, I assume, a sheet that is in your automated Excel session xlApp.
But when you use 'Selection' without specifying anything different, as you do in the code, you are referring to the Selection property of the Excel session that is running the code, not the session being automated, and I suspect this is not what you intend and is what is causing the problem. To fix, use xlApp.Selection wherever you have selection. HTH! "Geoff" wrote: I have built that creates a worksheet and everything works perfect except when I try to select the cells and change the font to Microsoft San Serif-8. I get the error message "The Remote Server Machine does not exist or is unavailable" My code is as follows: xlSheet.Range("A1").Select xlSheet.Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select With Selection.Font .NAME = "Microsoft Sans Serif" .Size = 8 End With xlApp.Application.Visible = True Any suggestions are greatly appreciated! |
All times are GMT +1. The time now is 05:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com