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

Re^2: Using OLE to view given Paragraph in MS Word Document

by Ray Smith (Beadle)
on Nov 22, 2011 at 00:40 UTC ( [id://939348]=note: print w/replies, xml ) Need Help??


in reply to Re: Using OLE to view given Paragraph in MS Word Document
in thread Using OLE to view given Paragraph in MS Word Document

Thanks for the example.

I tried it, first:
1. using my own test file.
2. Changing to use 5.10, because that's what I have.
3. use abs_path(input) file because Word appears to require absolute path.

Things operate with out error, but my Windows display still leaves the cursor at the beginning of the file.

Am I missing something here?

Replies are listed 'Best First'.
Re^3: Using OLE to view given Paragraph in MS Word Document
by ricDeez (Scribe) on Nov 22, 2011 at 08:12 UTC

    I don't really understand what you want to do!

    If you need to view the paragraphs being selected you could add the following:

    for my $i ( 1 .. $paragraphs->Count()){ last if $i > $ParaNo; $paragraph = $paragraphs->Item( $i ); $paragraph->{Range}->Select(); # <<<<<Added sleep(1); # <<<<<Added my $style = $paragraph->{Style}->{NameLocal}; my $text = $paragraph->{Range}->{Text}; print "style=$style text=$text\n"; }

    I have used placed the sleep in the loop so that you can see the paragraphs being selected in turn, otherwise it would just happen too quickly - especially since you are only interested in the first 10 paragraphs!

      Your advice was spot on! This is what I was missing, to view the specified paragraph:
      $paragraph = $paragraphs->Item( $i ); $paragraph->{Range}->Select(); # <<<<<Added
      I appologize for not being clear. I have a simple application that uses Microsoft Word for user generated input source. My goal, which I can now approach with your help, is, when an error in this user input file is discovered, to bring up the source file with the view positioned to facilitate the user making required modifications to correct the error(s).

      Thanks again for the help.

        I am glad to be of help. I am fairly new to Perl myself but have quite a bit of experience in developing MS Office automation applications. They are just more fun doing in Perl!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://939348]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-03-28 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found