Using Excel without Macros

Discussion in 'Perl Misc' started by Henning, Aug 3, 2009.

  1. Henning

    Henning Guest

    Hello!
    I have "inherited" the following code:

    use Win32::OLE::Const 'Microsoft Excel';
    $Win32::OLE::Warn = 3;
    $Excel = Win32::OLE->new('Excel.Application', 'Quit'); # get a new
    excel
    $Book1 = $Excel->Workbooks->Open("$abs_file_name"); # open Excel
    file

    When opening Excel (line 4) excel tries to start any macros associated
    with the file.
    Is there a way to avoid this (meaning: force excel to open the file
    with disabled macros)?
    And how to do so?

    Thanks a lot
    Henning
     
    Henning, Aug 3, 2009
    #1
    1. Advertising

  2. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Henning wrote:
    > Hello!
    > I have "inherited" the following code:
    >
    > use Win32::OLE::Const 'Microsoft Excel';
    > $Win32::OLE::Warn = 3;
    > $Excel = Win32::OLE->new('Excel.Application', 'Quit'); # get a new
    > excel
    > $Book1 = $Excel->Workbooks->Open("$abs_file_name"); # open Excel
    > file
    >
    > When opening Excel (line 4) excel tries to start any macros associated
    > with the file.
    > Is there a way to avoid this (meaning: force excel to open the file
    > with disabled macros)?
    > And how to do so?
    >
    > Thanks a lot
    > Henning

    Hello,

    first I think this is a user level problem, which can't be solved at programming
    level.
    Since the user can set if he want's to run those macros or not.

    Then I fond someting in addtion to the standart way to remove macros:

    http://www.eng-tips.com/faqs.cfm?fid=48

    regards,
    johannes keßler
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v2.0.11 (GNU/Linux)

    iEYEARECAAYFAkp2yMoACgkQE++2Zdc7EtdztwCff0LlN4DX+07+sQj5vz6Bvxxm
    TyoAnRbZ164f+faz/JzRAfyCvlH3xOJ7
    =zaSu
    -----END PGP SIGNATURE-----
     
    johannes keßler, Aug 3, 2009
    #2
    1. Advertising

  3. Henning wrote:
    > Hello!
    > I have "inherited" the following code:
    >
    > use Win32::OLE::Const 'Microsoft Excel';
    > $Win32::OLE::Warn = 3;
    > $Excel = Win32::OLE->new('Excel.Application', 'Quit'); # get a new
    > excel
    > $Book1 = $Excel->Workbooks->Open("$abs_file_name"); # open Excel
    > file
    >
    > When opening Excel (line 4) excel tries to start any macros associated
    > with the file.
    > Is there a way to avoid this (meaning: force excel to open the file
    > with disabled macros)?
    > And how to do so?
    >
    > Thanks a lot
    > Henning


    for Excel 2007, this is controlled with the AutomationSecurity property
    of the application. The help gives an example of how to do exactly what
    you are asking (in VB, not perl)

    --
    -brian
     
    Brian Helterline, Aug 3, 2009
    #3
  4. Henning

    Justin C Guest

    On 2009-08-03, Henning <> wrote:
    > Hello!
    > I have "inherited" the following code:
    >
    > use Win32::OLE::Const 'Microsoft Excel';
    > $Win32::OLE::Warn = 3;
    > $Excel = Win32::OLE->new('Excel.Application', 'Quit'); # get a new
    > excel
    > $Book1 = $Excel->Workbooks->Open("$abs_file_name"); # open Excel
    > file
    >
    > When opening Excel (line 4) excel tries to start any macros associated
    > with the file.
    > Is there a way to avoid this (meaning: force excel to open the file
    > with disabled macros)?
    > And how to do so?


    Use Spreadsheet::ReadExcel (or Spreadsheet::WriteExcel) instead? It
    depends what you are wanting to do. Excel starting and running macros
    automatically is something Excel does, I believe there is somewhere in
    Excel to turn this off. If you need to actually start Excel from Perl I
    don't think it's possible to do what you want, that's Excel specific,
    not Perl.

    Justin.

    --
    Justin C, by the sea.
     
    Justin C, Aug 4, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    80
    Views:
    2,522
    Stephen J. Bevan
    Nov 7, 2003
  2. Replies:
    1
    Views:
    492
    Marco Antoniotti
    Oct 7, 2003
  3. Replies:
    5
    Views:
    514
  4. Michael T. Babcock

    Re: Explanation of macros; Haskell macros

    Michael T. Babcock, Nov 3, 2003, in forum: Python
    Replies:
    0
    Views:
    543
    Michael T. Babcock
    Nov 3, 2003
  5. Andrew Arro

    macros-loop? calling macros X times?

    Andrew Arro, Jul 23, 2004, in forum: C Programming
    Replies:
    2
    Views:
    517
    S.Tobias
    Jul 24, 2004
Loading...

Share This Page