SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Картинка из Word



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
XXX_:)
Аналитик
Аналитик


Age: 40
Joined: 01 Feb 2008
Posts: 387
Location: Воронеж

PostPosted: Wed Jun 26, 2013 9:35 pm    Post subject: Картинка из Word Reply with quote

Добрый день, пока постановка следующая, в документе word лежит картинка. Нужно ее из этого документа забрать...
_________________
Hормальные люди делают вещи намного более безумные чем всё, что делают сумасшедшие (c) С.Лем
Back to top
View user's profile Send private message Blog
vga
Мастер
Мастер


Age: 200
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Wed Jun 26, 2013 10:33 pm    Post subject: Reply with quote

Привет!
Нашел только perl пример, по крайней мере есть направление, куда копать.

You need InlineShapes() and Shapes for this:


Quote:
InlineShape Object

Represents an object in the text layer of a document. An inline shape can only be a picture, an OLE object, or an ActiveX control. InlineShape objects are treated like characters and are positioned as characters within a line of text. The InlineShape object is a member of the InlineShapes collection. The InlineShapes collection contains all the shapes in a document, range, or selection.
Using the InlineShape Object

Use InlineShapes(index), where index is the index number, to return a single InlineShape object. Inline shapes don't have names. The following example activates the first inline shape in the active document.

ActiveDocument.InlineShapes(1).Activate


Remarks

Shape objects are anchored to a range of text but are free-floating and can be positioned anywhere on the page. You can use the ConvertToInlineShape method and the ConvertToShape method to convert shapes from one type to the other. You can convert only pictures, OLE objects, and ActiveX controls to inline shapes. Use the Type property to return the type of inline shape: picture, linked picture, embedded OLE object, linked OLE object, or ActiveX control.

When you open a document created in an earlier version of Word, pictures are converted to inline shapes.

Code:
#!/usr/bin/perl

use Modern::Perl;
use Win32::OLE;

my $Word = Win32::OLE->GetActiveObject('Word.Application')
  || Win32::OLE->new('Word.Application');
$Word->{'Visible'} = 0;
$Word->{DisplayAlerts} = 0;

my $document = $Word->Documents->Open("test.docx");

my $shapes = $document->InlineShapes(); #you need to process $document->Shapes() also


my $enumerate = new Win32::OLE::Enum($shapes);
while ( defined( my $shape = $enumerate->Next() ) ) {

    say "Width: ", $shape->Width();
}


_________________
Молитва - это запрос разработчику на изменение кода программы.
Back to top
View user's profile Send private message Blog Visit poster's website
6o6ep
Участник
Участник



Joined: 03 Jul 2012
Posts: 5

PostPosted: Thu Jul 04, 2013 10:33 am    Post subject: Reply with quote

Еще зависит от того, как она лежит: как картинка в тексте (InlineShapes), или как картинка сама по себе (Shapes).
С первым вариантом работал, правда была противоположная задача - вставить картинку Smile В итоге делал макросом. Наверное как простой вариант - можно макросом ее выделить и скопировать в буфер.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.