View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
K Dales[_2_] K Dales[_2_] is offline
external usenet poster
 
Posts: 1,163
Default 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!