Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Is there a key binding for the toolbar button?</p> <p>If there is, you could use the SendKeys method to send that key to Excel: <a href="http://msdn.microsoft.com/en-us/library/aa202943(office.10).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa202943(office.10).aspx</a></p> <p>Alternatively, the <strong>CommandBars</strong> collection might be useful. See <a href="http://msdn.microsoft.com/en-us/library/aa171356(office.11).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa171356(office.11).aspx</a> for reference.</p> <p>The sample code below lists the visible command bars and the controls in the 'Standard' toolbar. When it finds a control with the caption <em>Open</em>, it invokes the control. This should display the "File -> Open" dialog:</p> <pre><code>#!/usr/bin/perl use strict; use warnings; use Win32::OLE qw(in with); $Win32::OLE::Warn = 3; my $app = get_excel(); $app-&gt;{Visible} = 1; my $book = $app-&gt;Workbooks-&gt;Add; for my $bar (in $app-&gt;CommandBars) { if ( $bar-&gt;{Visible} ) { print $bar-&gt;{Name}, "\n"; } } print "Controls in the 'Standard' toolbar:\n"; my $bar = $app-&gt;CommandBars-&gt;{Standard}; for my $control (in $bar-&gt;{Controls}) { print "\t", $control-&gt;{Caption}, "\n"; if ( $control-&gt;{Caption} =~ /^Open/ ) { print "opening ...\n"; $control-&gt;Execute; } } sub get_excel { my $excel; eval { $excel = Win32::OLE-&gt;GetActiveObject('Excel.Application'); }; die "$@\n" if $@; unless(defined $excel) { $excel = Win32::OLE-&gt;new('Excel.Application', sub { $_[0]-&gt;Quit }) or die "Oops, cannot start Excel: ", Win32::OLE-&gt;LastError, "\n"; } return $excel; } __END__ </code></pre> <p>HTH</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload