From: Pete Dashwood on
B-Riemke wrote:
> On Jan 8, 11:09 pm, "Pete Dashwood"
> <dashw...(a)removethis.enternet.co.nz> wrote:
>> B-Riemke wrote:
>>> On Jan 5, 11:14 pm, "Pete Dashwood"
>>> <dashw...(a)removethis.enternet.co.nz> wrote:
>>>> B-Riemke wrote:
>>>>> Hi,
>>>>> i have a problem with Excel 2007.
>>
>>>>> The OLE Fuction "setPrintArea" is working in all Excel Versions
>>>>> but not in the Version 2007.
>>
>>>>> Have anyone test this Funkction under Excel 2007?
>>
>>>>> Best Regards
>>
>>>>> Bernd
>>
>>>> I have been using Excel 2007 without problem from Fujitsu NetCOBOL
>>>> and C#.
>>
>>>> Can you tell us exactly how it fails? What is the COM return code?
>>>> Sample code?
>>
>>>> I haven't used this particular function, but it obviously SHOULD
>>>> work.
>>
>>>> Does it simply not print? Have you tried print preview? Do you have
>>>> object references to Excel, the Workbook and the Worksheet all
>>>> previously established?
>>
>>>> This SHOULD be a simple matter of telling SetPrintArea the range
>>>> you want printed then printing it.
>>
>>>> Are you sure you are referencing the current worksheet? (If you
>>>> saved it already it may need re-referencing.)
>>
>>>> Post your code if you want further help.
>>
>>>> Pete.
>>
>>>> --
>>>> "I used to write COBOL...now I can do anything."
>>
>>> ********************************************************
>>> *
>>> * Macro from Excel 2007:
>>> * ActiveSheet.PageSetup.PrintArea = "$A$1:$EA$267"
>>> * This is working under all versions but not under 2007
>>> *
>>> ********************************************************
>>
>>> Move z"1:267" TO X-00-TEXT
>>
>>> INVOKE WorkBook "getActiveSheet" RETURNING ActiveSheet.
>>
>>> INVOKE ActiveSheet "getPageSetup" Returning PageSetup.
>>
>>> INVOKE PageSetup "setPrintArea" using X-00-TEXT
>>
>>> ******************************************************
>>
>> That looks OK, but you haven't told us what the HResult is. That
>> gives a clue as to why it isn't working.
>>
>> Try and forget that it works in other versions, that doesn't help the
>> immediate problem, which you need to see as if it were new.
>>
>> It seems very likely to me that the problem is being caused by the
>> value of X-00-TEXT.
>>
>> Have you tried setting a standard range in there like:
>> "$A$1:$EA$267" ?
>>
>> I'd try some experiments with this, like a value of "$A$1:$A$1" and
>> see if it will print a single cell. This will at least establish
>> whether the problem is in the print function or with the range
>> specified for the worksheet.
>>
>> Pete.
>>
>> --
>> "I used to write COBOL...now I can do anything."- Hide quoted text -
>>
>> - Show quoted text -
>
> I have testet "$A$1:$EA$267" but I become
>
> OLE Error 1 (OLE Server error)
>
> Exeption Number 65537
>
> I think that there is a Microsoft Excel 2007 Bug

I think that is possible, but unlikely :-) Even if it were true, you still
need to get it working so it might be good to find a workaround, no?
>
> If you search via Google for "excel 2007 set print area" you can see
> that there are some problems with that function.

I see people having problems with stuff, just as people have problems with
stuff all the time. If there were a bug in this, given that it has been
published for over 3 years, and the bug prevents it working, Microsoft would
have patched or fixed it by now.

The error you are receiving is generally caused by the Automation server not
being registered correctly.

(http://www.microfocus.com/Resources/Newsletters/CustomerCare/2004/2004-03/20040301_001.asp)

As the Automation server is Excel, it is not likely that it isn't registered
correctly, so there must be another problem. Typically, the type of thing
that would cause this would be invoking a mis-spelled or non-existent method
name. If you are sure that is not the case, then the problem is probably
conflicting versions of Excel

If you have a previous version of Office co-existing with Office 2007 it is
possible that the Automation server for Excel is instantiating the "wrong"
version.

When you instantiate the Automation server, try using the version in the
progID: "Excel.Application.12" instead of the version independent form
"Excel.Application". (It SHOULD default to the latest version but who knows?
It is complex software...)

If it still fails, you could try removing the old version of Office (or
Excel) and see if the problem still occurs.

If I get a chance I'll try and duplicate your problem.

Pete.
--
"I used to write COBOL...now I can do anything."


From: Pete Dashwood on
Pete Dashwood wrote:
> B-Riemke wrote:
>> On Jan 8, 11:09 pm, "Pete Dashwood"
>> <dashw...(a)removethis.enternet.co.nz> wrote:
>>> B-Riemke wrote:
>>>> On Jan 5, 11:14 pm, "Pete Dashwood"
>>>> <dashw...(a)removethis.enternet.co.nz> wrote:
>>>>> B-Riemke wrote:
>>>>>> Hi,
>>>>>> i have a problem with Excel 2007.
>>>
>>>>>> The OLE Fuction "setPrintArea" is working in all Excel Versions
>>>>>> but not in the Version 2007.
>>>
>>>>>> Have anyone test this Funkction under Excel 2007?
>>>
>>>>>> Best Regards
>>>
>>>>>> Bernd
>>>
>>>>> I have been using Excel 2007 without problem from Fujitsu NetCOBOL
>>>>> and C#.
>>>
>>>>> Can you tell us exactly how it fails? What is the COM return code?
>>>>> Sample code?
>>>
>>>>> I haven't used this particular function, but it obviously SHOULD
>>>>> work.
>>>
>>>>> Does it simply not print? Have you tried print preview? Do you
>>>>> have object references to Excel, the Workbook and the Worksheet
>>>>> all previously established?
>>>
>>>>> This SHOULD be a simple matter of telling SetPrintArea the range
>>>>> you want printed then printing it.
>>>
>>>>> Are you sure you are referencing the current worksheet? (If you
>>>>> saved it already it may need re-referencing.)
>>>
>>>>> Post your code if you want further help.
>>>
>>>>> Pete.
>>>
>>>>> --
>>>>> "I used to write COBOL...now I can do anything."
>>>
>>>> ********************************************************
>>>> *
>>>> * Macro from Excel 2007:
>>>> * ActiveSheet.PageSetup.PrintArea = "$A$1:$EA$267"
>>>> * This is working under all versions but not under 2007
>>>> *
>>>> ********************************************************
>>>
>>>> Move z"1:267" TO X-00-TEXT
>>>
>>>> INVOKE WorkBook "getActiveSheet" RETURNING ActiveSheet.
>>>
>>>> INVOKE ActiveSheet "getPageSetup" Returning PageSetup.
>>>
>>>> INVOKE PageSetup "setPrintArea" using X-00-TEXT
>>>
>>>> ******************************************************
>>>
>>> That looks OK, but you haven't told us what the HResult is. That
>>> gives a clue as to why it isn't working.
>>>
>>> Try and forget that it works in other versions, that doesn't help
>>> the immediate problem, which you need to see as if it were new.
>>>
>>> It seems very likely to me that the problem is being caused by the
>>> value of X-00-TEXT.
>>>
>>> Have you tried setting a standard range in there like:
>>> "$A$1:$EA$267" ?
>>>
>>> I'd try some experiments with this, like a value of "$A$1:$A$1" and
>>> see if it will print a single cell. This will at least establish
>>> whether the problem is in the print function or with the range
>>> specified for the worksheet.
>>>
>>> Pete.
>>>
>>> --
>>> "I used to write COBOL...now I can do anything."- Hide quoted text -
>>>
>>> - Show quoted text -
>>
>> I have testet "$A$1:$EA$267" but I become
>>
>> OLE Error 1 (OLE Server error)
>>
>> Exeption Number 65537
>>
>> I think that there is a Microsoft Excel 2007 Bug
>
> I think that is possible, but unlikely :-) Even if it were true, you
> still need to get it working so it might be good to find a
> workaround, no?
>>
>> If you search via Google for "excel 2007 set print area" you can see
>> that there are some problems with that function.
>
> I see people having problems with stuff, just as people have problems
> with stuff all the time. If there were a bug in this, given that it
> has been published for over 3 years, and the bug prevents it working,
> Microsoft would have patched or fixed it by now.
>
> The error you are receiving is generally caused by the Automation
> server not being registered correctly.
>
> (http://www.microfocus.com/Resources/Newsletters/CustomerCare/2004/2004-03/20040301_001.asp)
>
> As the Automation server is Excel, it is not likely that it isn't
> registered correctly, so there must be another problem. Typically,
> the type of thing that would cause this would be invoking a
> mis-spelled or non-existent method name. If you are sure that is not
> the case, then the problem is probably conflicting versions of Excel
>
> If you have a previous version of Office co-existing with Office 2007
> it is possible that the Automation server for Excel is instantiating
> the "wrong" version.
>
> When you instantiate the Automation server, try using the version in
> the progID: "Excel.Application.12" instead of the version
> independent form "Excel.Application". (It SHOULD default to the
> latest version but who knows? It is complex software...)
>
> If it still fails, you could try removing the old version of Office
> (or Excel) and see if the problem still occurs.
>
> If I get a chance I'll try and duplicate your problem.
>
> Pete.

I dug out a copy of the Excel object model.

Try using "PrintArea" instead of "setPrintArea".

It is an attribute of the "PageSetup" object which does the same job and
takes the same parameters.

HTH,

Pete.

--
"I used to write COBOL...now I can do anything."