Y
Yar Glazkov
Hi, nongurus. Hi, gurus.
As far as i could found, nobody (i.e. less than half) knows how to name the
newly created workbook in Excel without saving it. So did not I until
yesterday. But my prayings was heard and Someone came down from Above and
told me what to do. I've done it and it worked so-so.
So, little more serious. As you maybe know, you can neither assign
Workbook:Name property, nor supply the workbook name when executing
Workbooks:Add() method. Workbook is named <Template name>1 (..2, ..3, ...)
until it is Workbook:SaveAs. If Workbook:Add() is called without template
name, it is named Book1. So, the way of user naming comes from this
convention, and is:
(The code fragments shown below has come from language not common to
everybody - Progress ABL - but seems to me that it is quit understandable)
I. When creating from template
I1) Copy template to tempdir under name you like.
temporary-template-file = Session:temp-dir + 'Name I Like .xlt'.
OS-COPY value(template-file) value(temporary-template-file).
I2) Create workbook from this template
ChWorkBook = chExcel:Workbooks:Add(temporary-template-file).
I3) Delete temporary file
OS-DELETE value(temporary-template-file).
II. When creating not from template
II1) Create new workbook
II2) Save it as template with name you like in tempdir
II3) GOTO I2
Unfortunaly, using this workaround, you always create the workbook with "1"
in the end of the name. But what to do with this, I don't know. In my case,
fortunaly, Workbook:Name was to end with time, and I tricked - my seconds
always end with 1.
I hope I helped someone
As far as i could found, nobody (i.e. less than half) knows how to name the
newly created workbook in Excel without saving it. So did not I until
yesterday. But my prayings was heard and Someone came down from Above and
told me what to do. I've done it and it worked so-so.
So, little more serious. As you maybe know, you can neither assign
Workbook:Name property, nor supply the workbook name when executing
Workbooks:Add() method. Workbook is named <Template name>1 (..2, ..3, ...)
until it is Workbook:SaveAs. If Workbook:Add() is called without template
name, it is named Book1. So, the way of user naming comes from this
convention, and is:
(The code fragments shown below has come from language not common to
everybody - Progress ABL - but seems to me that it is quit understandable)
I. When creating from template
I1) Copy template to tempdir under name you like.
temporary-template-file = Session:temp-dir + 'Name I Like .xlt'.
OS-COPY value(template-file) value(temporary-template-file).
I2) Create workbook from this template
ChWorkBook = chExcel:Workbooks:Add(temporary-template-file).
I3) Delete temporary file
OS-DELETE value(temporary-template-file).
II. When creating not from template
II1) Create new workbook
II2) Save it as template with name you like in tempdir
II3) GOTO I2
Unfortunaly, using this workaround, you always create the workbook with "1"
in the end of the name. But what to do with this, I don't know. In my case,
fortunaly, Workbook:Name was to end with time, and I tricked - my seconds
always end with 1.
I hope I helped someone