From: Claire on
Gary,
What UserControl = True is used for?
Thanks,
Claire
"GS" <gesansom(a)netscape.net> wrote in message
news:hung5c$3na$1(a)news.eternal-september.org...
> Sorry, but I failed to mention that it is good practice to always restore
> any persistent settings you change when automating any app. That said, you
> should store the existing SheetsInNewWorkbook setting in a variable and
> reset it after you add your workbook.
>
> Revised code snippet:
>
> Dim lCount As Long
> With appXL
> lCount = .SheetsInNewWorkbook
> .SheetsInNewWorkbook = 1
> .Workbooks.Add
> .SheetsInNewWorkbook = lCount
> 'do some more stuff, maybe
> .visible = True
> .UserControl = True
> End With
>
> --
> Garry
>
> Free usenet access at http://www.eternal-september.org
> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>
>


From: GS on
After serious thinking Claire wrote :
> Gary,
> What UserControl = True is used for?
> Thanks,
> Claire
> "GS" <gesansom(a)netscape.net> wrote in message
> news:hung5c$3na$1(a)news.eternal-september.org...
>> Sorry, but I failed to mention that it is good practice to always restore
>> any persistent settings you change when automating any app. That said, you
>> should store the existing SheetsInNewWorkbook setting in a variable and
>> reset it after you add your workbook.
>>
>> Revised code snippet:
>>
>> Dim lCount As Long
>> With appXL
>> lCount = .SheetsInNewWorkbook
>> .SheetsInNewWorkbook = 1
>> .Workbooks.Add
>> .SheetsInNewWorkbook = lCount
>> 'do some more stuff, maybe
>> .visible = True
>> .UserControl = True
>> End With
>>
>> -- Garry
>>
>> Free usenet access at http://www.eternal-september.org
>> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>>
>>

UserControl = True turns the instance over to the user for use by the
user. This means your app no longer has exclusive control. I expect
you'd only use this if your app was Excel-based. Otherwise, if you want
to have complete control over the automated instance while it's running
then don't use it.

Also, the only reason to make the instance visible <IMO> is to allow
users to view or interact with any files you've opened. Your app can
control the interaction or you could turn control over to the user via
setting the UserControl prop. By default, that prop is FALSE for
automated instances of MSO apps.

HTH

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


From: Claire on
It is a pleasure to read your replies.
Thanks, Gary.

"GS" <gesansom(a)netscape.net> wrote in message
news:huoan8$a0c$1(a)news.eternal-september.org...
> After serious thinking Claire wrote :
>> Gary,
>> What UserControl = True is used for?
>> Thanks,
>> Claire
>> "GS" <gesansom(a)netscape.net> wrote in message
>> news:hung5c$3na$1(a)news.eternal-september.org...
>>> Sorry, but I failed to mention that it is good practice to always
>>> restore any persistent settings you change when automating any app. That
>>> said, you should store the existing SheetsInNewWorkbook setting in a
>>> variable and reset it after you add your workbook.
>>>
>>> Revised code snippet:
>>>
>>> Dim lCount As Long
>>> With appXL
>>> lCount = .SheetsInNewWorkbook
>>> .SheetsInNewWorkbook = 1
>>> .Workbooks.Add
>>> .SheetsInNewWorkbook = lCount
>>> 'do some more stuff, maybe
>>> .visible = True
>>> .UserControl = True
>>> End With
>>>
>>> -- Garry
>>>
>>> Free usenet access at http://www.eternal-september.org
>>> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>>>
>>>
>
> UserControl = True turns the instance over to the user for use by the
> user. This means your app no longer has exclusive control. I expect you'd
> only use this if your app was Excel-based. Otherwise, if you want to have
> complete control over the automated instance while it's running then don't
> use it.
>
> Also, the only reason to make the instance visible <IMO> is to allow users
> to view or interact with any files you've opened. Your app can control the
> interaction or you could turn control over to the user via setting the
> UserControl prop. By default, that prop is FALSE for automated instances
> of MSO apps.
>
> HTH
>
> --
> Garry
>
> Free usenet access at http://www.eternal-september.org
> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>
>


From: Dee Earley on
On 09/06/2010 07:28, GS wrote:
> Claire laid this down on his screen :
>> "Claire" <replyto(a)fra> wrote in message
>> news:eD4hhm4BLHA.5584(a)TK2MSFTNGP06.phx.gbl...
>>> Hello,
>>> When using Excel automation:
>>> .Open command requires the full path to the file (workbook)
>>> I need to open just blank, unnamed spreadsheet.
>>> How to do that?
>>> Thanks, Claire
>> I have found that doing:
>> .Visible = True
>> and then using .Add it will show opened Excel book containing 3 blank
>> sheets.
>> Why there are 3 sheets?
>> I need to start a book with one blank sheet only.
>> Thanks, Claire
>
> The number of worksheets when adding a new workbook will always be the
> value of Application.SheetsInNewWorkbook property. To only have 1 sheet
> in a new workbook:

Or remove them (using code)

I've always hated that default setting, but i suppose no one will notice
the feature if there is just one.
A slightly more intelligent design (like IE, chrome, etc) with a "new"
tab would have done

--
Dee Earley (dee.earley(a)icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
From: GS on
Dee Earley presented the following explanation :
> On 09/06/2010 07:28, GS wrote:
>> Claire laid this down on his screen :
>>> "Claire" <replyto(a)fra> wrote in message
>>> news:eD4hhm4BLHA.5584(a)TK2MSFTNGP06.phx.gbl...
>>>> Hello,
>>>> When using Excel automation:
>>>> .Open command requires the full path to the file (workbook)
>>>> I need to open just blank, unnamed spreadsheet.
>>>> How to do that?
>>>> Thanks, Claire
>>> I have found that doing:
>>> .Visible = True
>>> and then using .Add it will show opened Excel book containing 3 blank
>>> sheets.
>>> Why there are 3 sheets?
>>> I need to start a book with one blank sheet only.
>>> Thanks, Claire
>>
>> The number of worksheets when adding a new workbook will always be the
>> value of Application.SheetsInNewWorkbook property. To only have 1 sheet
>> in a new workbook:
>
> Or remove them (using code)
>
> I've always hated that default setting, but i suppose no one will notice the
> feature if there is just one.
> A slightly more intelligent design (like IE, chrome, etc) with a "new" tab
> would have done

Hmm! I suppose that might be a realistic idea. I see Excel12 has a new
approach attached to its "New" menu. Not decided if any approach by M$
is better than configuring it how I want, though.

As for automating, it's pretty simple to store the existing property,
set as desired, then restore original afterwards. It's a bit easier to
handle than deleting however many sheets greater than a count of 1.
Less coding required to set as desired!<IMO>

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: VB Macro to VB Application
Next: invisible tag for RTF?