![]() I am giving this new document a specific name and location. ![]() In the above the active document is assigned to the variable htmDoc. HtmDoc.SaveAs2 FileName:=LGPWorking & strFileName, AddToRecentFiles:=False, FileFormat:= If you want to place all shapes (floating or inline) into a folder as image files, then the best way is to save the source document as a filtered HTML document. If > 0 Thenįor i = 1 To ĭoc.Content.InlineShapes(i).Range.CopyAsPicture 'they appear in the document then you have to convert 'if you want all extracted pictures to be in the sequence 'if you want only pictures extracted then you have If shp.Type = msoLinkedPicture Or shp.Type = msoPicture Then Sub CopyPasteAsPicture()ĭim doc As Word.Document, iShp As Word.InlineShape, shp As Word.Shapeĭim i As Integer, nDoc As Word.Document, rng As Word.Range Of course the For/Next loop that is required is slower no matter what. The speed problem of this type of code is caused by the CopyPicture working from a Selection command, so I recommend using a range instead. ![]() here is example code that will locate pictures in your source document and paste them into a second document. However, you said that was not a good fit for you needs so. Thanks in advance!Įxtracting the pictures from a Filtered HTML document that was created from your original source document would be faster. Pubdoc.Pages(1).Shapes(1).SaveAsPicture (dp & Application.PathSeparator & j & ".jpg")Īpart from this, if anyone has any suggestions to make this faster, I'm all ears. ![]() 'Set pubdoc = CreateObject("Publisher.Document") I'm calling this sub in another sub that is looping over all the files in a folder): Sub test(ByVal fp As String, ByVal dp As String, ByVal filename As String) Here is the code block that I've been working on (fp, dp are folder paths, while filename is the word document name. As per my understanding, it is due to memory allocation, but I'm not sure. However, I'm facing a Runtime Automation error when I'm running the script.įor using the Publisher runtime library I've tried both early and late binding but I'm facing the error on both of them.Ĭan anyone please let me know what is the problem? Also, if anyone can explain why I'm facing this error, that'd be great. ![]() Now, I'm looping through the images using inlineshapes object and then copy-pasting them on a publisher document and then saving them as an image. I've tried the method of saving them as an HTML document, but it is not a good fit for my requirement. I need to loop over some word documents, and extract images from a word document and save them in a separate folder. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |