Page 1 of 1

[Solved] Embed ASCII File in Spreadsheet

PostPosted: Fri Nov 30, 2018 12:41 pm
by VBandOoffice
Hi all,
I'm doing calibrations of measurement devices. Results are saved in a spreadsheet.

Now I've the idea to embed the settings of the measurement device in this spreadsheet, as well.
This settings are a small ASCII-File.

I tried to to rename this file to .bmp and to insert it like as a picture. But this is not working.
(Rename from .ods to .zip and put the file to picture folder has not worked, too)

Does anybody knows if this is possible and how to do?

Best regards,
VBandOoffice

Re: Embed ASCII File in Spreadsheet

PostPosted: Fri Nov 30, 2018 1:03 pm
by John_Ha
1. Open the ASCII file with Notepad
2. Copy all
3. Paste into Calc.

Or

1. Open the ASCII file with Notepad
2. Press Alt+PrtScr to copy Notepad window as a
3. Paste image into Calc.
4. Repeat as required.

Showing that a problem has been solved helps others searching so, if your problem is now solved, please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.

Re: Embed ASCII File in Spreadsheet

PostPosted: Fri Nov 30, 2018 2:03 pm
by VBandOoffice
Yes, this will work. But I'm looking for a solution to embed the file - not only the ASCII text.

If I don't find the solution, I'm searching for, maybe I will use this one.

Regards,
VBandOoffice

Re: Embed ASCII File in Spreadsheet

PostPosted: Fri Nov 30, 2018 2:50 pm
by John_Ha
See Linking to external data and following on pages 270 - 282 of the Calc Guide.

This is Insert > Object > OLE Object > Further objects > tick Create from file > Navigate to some text.txt stored on my Desktop. I have the option to bring in the file or to link to it.

This is the macro I recorded while doing so: When running it It opens the window at Insert > Object > OLE Object ..., and I have to complete the selection.

Code: Select all   Expand viewCollapse view
sub zz_ole
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertObject", "", 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertObject", "", 0, Array())

end sub

See also 7.11. Insert An OLE Object in Pitonyak's book which is for inserting in Writer.

Code: Select all   Expand viewCollapse view
7.11. Insert An OLE Object
The rumor is that with OpenOffice version 1.1, the following code will insert an OLE object
into a write document. The CLSID may be an external OLE object.
Listing 7.37: Insert an OLE object.
SName = "com.sun.star.text.TextEmbeddedObject"
obj = ThisComponent.createInstance(sName)
obj.CLSID = "47BBB4CB-CE4C-4E80-A591-42D9AE74950F"
obj.attach(ThisComponent.currentController().Selection.getByIndex(0))
If you select an embedded object in writer, you can access its API with:
oModel = ThisComponent.currentController().Selection.Model
This provides the same interface to the object as if you created the object by loading a
document with loadComponentFromURL

Re: Embed ASCII File in Spreadsheet

PostPosted: Mon Dec 03, 2018 9:58 am
by VBandOoffice
Hi John_Ha,
thank you very much - this looks pretty good to me. I will test it and post result (maybe this will take one or two days).

Best regards,
VBandOoffice