Hi all!
how to save all images in jpg and replacement of graphics to the file name?
img_01.jpg
img_02.jpg
etc
p.s. MacOS
[Solved] How to save all images from SpreadSheet?
[Solved] How to save all images from SpreadSheet?
Last edited by Hagar Delest on Thu Jun 15, 2017 1:26 pm, edited 1 time in total.
Reason: tagged [Solved].
Reason: tagged [Solved].
OpenOffice 4.1.3 / MacOS 10.11.6
Re: How to save all images from SpreadSheet?
An ODF document is just a zip archive. On my Linux system I can do the following:
this extracts the document's Pictures folder.
Code: Select all
unzip docname.ods Pictures/*
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: How to save all images from SpreadSheet?
need save Files and replace pictures in sells to filenames
for Excel i have VB script, but in OpenOffice not working
for Excel i have VB script, but in OpenOffice not working
Code: Select all
Sub Save_Object_As_Picture()
Dim li As Long, oObj As Shape, wsSh As Worksheet, wsTmpSh As Worksheet
Dim sImagesPath As String, sName As String
sImagesPath = ActiveWorkbook.Path & "/images/" '"
If Dir(sImagesPath, 16) = "" Then
MkDir sImagesPath
End If
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set wsSh = ActiveSheet
Set wsTmpSh = ActiveWorkbook.Sheets.Add
For Each oObj In wsSh.Shapes
If oObj.Type = 13 Then
li = li + 1
oObj.Copy
sName = "img" & li
With wsTmpSh.ChartObjects.Add(0, 0, oObj.Width, oObj.Height).Chart
.ChartArea.Border.LineStyle = 0
.Parent.Select
.Paste
.Export Filename:=sImagesPath & sName & ".jpg", FilterName:="JPG"
.Parent.Delete
End With
oObj.TopLeftCell.Value = sName
oObj.Delete '????_?? ???????? ? ?????
End If
Next oObj
Set oObj = Nothing: Set wsSh = Nothing
wsTmpSh.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "??????? ????????? ? ?????: " & sImagesPath, vbInformation, "www.excel-vba.ru"
End Sub
OpenOffice 4.1.3 / MacOS 10.11.6
-
- Posts: 145
- Joined: Mon Jun 13, 2016 10:50 am
Re: How to save all images from SpreadSheet?
Give this a try:
Code: Select all
sub export_replace_img
doc = thiscomponent
a_url = split(doc.URL, "/")
GP = createUnoService("com.sun.star.graphic.GraphicProvider")
dim props(1) as new com.sun.star.beans.PropertyValue
props(0).Name = "URL"
props(1).Name = "MimeType"
for each sheet in doc.Sheets
drawpage = sheet.DrawPage
for n = drawpage.Count-1 to 0 step -1
elem = drawpage.getByIndex(n)
if elem.supportsService("com.sun.star.drawing.GraphicObjectShape") then
if elem.Graphic.MimeType = "image/jpeg" then
a_url(ubound(a_url)) = elem.Name & ".jpg"
props(0).Value = convertToURL(join(a_url, "/"))
props(1).Value = elem.Graphic.MimeType
GP.storeGraphic(elem.Graphic, props)
on error resume next 'image could be anchored to page
elem.Anchor.setString(elem.Name)
drawpage.remove(elem)
end if
end if
next n
next sheet
msgbox "done"
end sub
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
Re: How to save all images from SpreadSheet?
Not working...
Maybe the original file will help ?
https://drive.google.com/open?id=0B87VT ... TROV0ZGb0k
Maybe the original file will help ?
https://drive.google.com/open?id=0B87VT ... TROV0ZGb0k
OpenOffice 4.1.3 / MacOS 10.11.6
-
- Posts: 145
- Joined: Mon Jun 13, 2016 10:50 am
Re: How to save all images from SpreadSheet?
Checking for image type was useless. Here is a working example:
Code: Select all
sub export_replace_img
doc = thiscomponent
a_url = split(doc.URL, "/")
GP = createUnoService("com.sun.star.graphic.GraphicProvider")
dim props(1) as new com.sun.star.beans.PropertyValue
props(0).Name = "URL"
props(1).Name = "MimeType"
for each sheet in doc.Sheets
drawpage = sheet.DrawPage
for n = drawpage.Count-1 to 0 step -1
elem = drawpage.getByIndex(n)
if elem.supportsService("com.sun.star.drawing.GraphicObjectShape") then
a_url(ubound(a_url)) = elem.Name & ".jpg"
props(0).Value = convertToURL(join(a_url, "/"))
props(1).Value = elem.Graphic.MimeType
GP.storeGraphic(elem.Graphic, props)
on error resume next 'image could be anchored to page
elem.Anchor.setString(elem.Name)
drawpage.remove(elem)
end if
next n
next sheet
msgbox "done"
end sub
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
Re: How to save all images from SpreadSheet?
Works !
thank you very much!
and wish that the names were appointed to force Img_xx.jpg ?
thank you very much!
and wish that the names were appointed to force Img_xx.jpg ?
OpenOffice 4.1.3 / MacOS 10.11.6