OK, there are some idiosyncrasies at work here, which can get confusing for this to work in your case, because the full context of your code is not evident.
FreezePanes is a property of a Window and of the ActiveWindow. Note, key words here (believe it or not) are "a" and "the".
The ActiveWindow is the window that is active, meaning it needs to be activated (selected) for it to be active, as there can only be one ActiveWindow in a single instance of Excel, hence the significance of the word "the".
A Window can be another workbook in the same instance of Excel, or a second Window in the same workbook such as if you click Window > New Window for the active workbook. In that respect, a Window does not need to be active for FreezePanes to be set. However, if for example you have Sheet1 active and you create a new window, and in that window you activate Sheet2, then re-activate your first (original) window to be on Sheet1 and you exectute
Windows(2).FreezePanes = True
it will freeze panes on Sheet2 in the second window but not Sheet2 on the window you are actively on.
So in your case, where this leaves you might be right smack in the middle, where you are creating an Excel object, which (and this is where I cannot tell) may or may not be in the same instance of Excel. If you are creating a seperate instance, that instance will not be recognized as a Window in the Windows collection of your active workbook.
If the Excel app yuou are creating is a part of your current active workbook's Window collection, you could execute this codeline to freeze panes on that unselected Window app...
Windows(2).FreezePanes = True
...assuming it is the second Window in your collection, as an example.
Otherwise, you are out of luck unless you make visible that xl object being created, make it active, and then set the Freeze Panes at that point.