Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hi marto.

use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; use Cwd; #my ($file) = @ARGV; #my $cwd_path = getcwd(); #$cwd_path=~ s/\//\\/gs; #my $file_name = "$cwd_path\\$file"; my $file_name = "c:\\entityandsymbol.doc"; my $Word = Win32::OLE->new('Word.Application'); $Word->{'Visible'} = 1; my $document = $Word->Documents->Open($file_name) || die("Unable to op +en document", Win32::OLE->LastError()); my $Selection = $Word->Selection; $Selection->HomeKey (wdStory); $Selection->TypeText("This is the inserted text"); $Selection->Collapse (wdCollapseEnd); $Selection->TypeParagraph; $Selection->TypeText("This is the inserted text 2"); $Selection->Collapse (wdCollapseEnd); $Selection->TypeParagraph; $Word->Documents($file_name)->Save(); $Word->Quit();

I am getting the error as follows:

Unable to open documentOLE exception from "Microsoft Word": Could not open macro storage. Win32::OLE(0.1701) error 0x800a175d in METHOD/PROPERTYGET "Open" at array.pl line 4630.

But the word file opening corectly without modification which I did in coding.

Suggest me in correct way.

Updated: I found the solution for the above problem as per "http://www.blink.com.au/tech/trouble.htm" information.

Could Not Open Macro Storage Error (Run-time error 5981)

When running BLINK you can get the error message "Could not open macro storage". This is caused by either not having Service Pack 1 installed with Microsoft® Office, or because the Visual Basic and Microsoft® Word installation has become corrupted.

To fix it you will need to either install Service Pack 1, if it has not been installed before, or reinstall Microsoft® Word.

I am reinstalled the Microsoft Word then the above code working fine.

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';


In reply to Re^2: VBA to Perl by Samy_rio
in thread VBA to Perl by sanPerl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (7)
    As of 2019-10-16 06:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?