Ask Your Question
0

"shape" throws and error

asked 2018-11-28 07:21:31 +0200

Todd2 gravatar image

Hi All,

I am trying to save a chart.

From https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=67781#p301942

Sub StoreDrawingOBjectAsImage
  shape = ThisComponent.getSheets().getByIndex(0).getDrawPage().getByIndex(0)

  Dim args(1) as new com.sun.star.beans.PropertyValue
  args(0).Name = "URL"
  args(0).Value = "file:///home/asuka/Downloads/foo.png"
  args(1).Name = "MimeType"
  args(1).Value = "image/png"

  gef = CreateUnoService("com.sun.star.drawing.GraphicExportFilter")
  gef.setSourceDocument(shape)
  gef.filter(args)
End Sub

"shape" throws "Basic Runtime Error 12". What I am doing wrong, this time?

Many thanks, -T

edit retag flag offensive close merge delete

Comments

Which "shape"? you have it mentioned twice in your script.

By the way, it works for me (modulo changing the path to point to my place: args(0).Value = "file:///D:/Documents/foo.png").

Hopefully you do have a chart on your first sheet of the active spreadsheet.

Mike Kaganski gravatar imageMike Kaganski ( 2018-11-28 10:22:50 +0200 )edit

It is on the second tab/sheet. What do I need to change?

Todd2 gravatar imageTodd2 ( 2018-11-28 20:46:37 +0200 )edit

shape = ThisComponent.getSheets().getByIndex(1).getDrawPage().getByIndex(0)

Mike Kaganski gravatar imageMike Kaganski ( 2018-11-28 21:47:56 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2018-11-28 18:03:10 +0200

Todd2 gravatar image

He forgot to declare "shape"

dim shape
edit flag offensive delete link more

Comments

Not "he", but you (when using a very useful option explicit which requires each variable to be declared using DIM before using).

Mike Kaganski gravatar imageMike Kaganski ( 2018-11-28 18:07:30 +0200 )edit

I am confused. Over on https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=67781#p301942 I do not see him declaring (with dim) the shape variable. Why do I need to declare and he does not?

Todd2 gravatar imageTodd2 ( 2018-12-01 00:18:53 +0200 )edit

As I have mentioned above, when you use option explicit in your module, you declare that any variable name must be declared before use, to avoid problems when you made a typo.

Books and sheets mentioned here might help you.

Mike Kaganski gravatar imageMike Kaganski ( 2018-12-01 07:24:54 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-11-28 07:21:31 +0200

Seen: 20 times

Last updated: Nov 28 '18