Script cannot be found

Creating a macro - Writing a Script - Using the API

Script cannot be found

Postby emf » Thu Mar 07, 2019 1:50 pm

When trying to run my scripts, I get an error alert like:

OpenOffice Error
A Scripting Framework error occurred while running the Basic script vnd.sun.star script Standard Module1 PasteUnformatted? Language-Basic & Location-Application.
Message: The following Basic script could not be found:
library: Standard
module: 'Module1'
method: PasteUnformatted
location: 'Application'

I have a copy of the
I checked in the user\Basic\Standard folder and there is a file Module1.sba file. The same with my other scripts. Why OO can't find them?
OO 4.1.6 in 64 bit Windows 10
User avatar
emf
 
Posts: 79
Joined: Tue Aug 12, 2008 8:44 am
Location: New York

Re: Script cannot be found

Postby RoryOF » Thu Mar 07, 2019 1:59 pm

Surely that should read Module1.xba, not .sba?
Apache OpenOffice 4.1.6 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29432
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Script cannot be found

Postby Lupp » Thu Mar 07, 2019 2:10 pm

I have no .sba files anywhere. Did you mean Module1.xbq ;) ?
Now seriously: You cannot provide the routines contained in a Basic module 'Module1' by simply copying the Module1.xba into the Basic folder of your user profile. You need to import the module from a document using the Basic Organizer, or to create it anew with the Basic Editor. There you may paste in the source as plain text.
This way the module gets registered in the file script.xlb, and some characters contained in the modules are converted to escape sequences of the ampersand (HTML) type when the module is saved.
It's not exactly simple to substitute these processes by handiwork.
On Windows 10: LibreOffice 6.2 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2523
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Script cannot be found

Postby emf » Fri Mar 08, 2019 1:35 pm

Of course xba. Sorry for the typo.
Now, let's see:
Tools > Macros > Organize Macros > Organize Basic...
then:
My Macros > Basic > Module1 > Main > Edit
On the right side I see only Main, and when I open to edit it it only contains 2 lines:

Sub Main
End Sub

I remember opening the file with all my macros, which I had to edit sometimes in the past. Now, when I open the Module1.xba in the Notepad, I find all my macros, as I remember editing them in the past. Clearly OO does not open this file.
Should I copy the contents from the Notepad into the Main and save it?
And in which directory is the file with the empty Main that OO reads, since it's not the Module1.xba in the Basic\Standard\ directory...
OO 4.1.6 in 64 bit Windows 10
User avatar
emf
 
Posts: 79
Joined: Tue Aug 12, 2008 8:44 am
Location: New York

Re: Script cannot be found

Postby Lupp » Fri Mar 08, 2019 2:04 pm

emf wrote:Should I copy the contents from the Notepad into the Main and save it?

The empty Sub Main simply is the default content of an otherwise empty module newly created. Delete it.
As I already told you, you can create/make accessible your macros anew by pasting them into an new module. (Choose a new name for that module to avoid name conflicts! Do NOT save a newly created Module1! It might overwrite your inactive module, I'm afraid. Best don't tamper any more with the script container at all. Reading / copying the files only wont't hurt.)

But most likely they will not work without additional measures:
You need to revert the HTML-encoding of special characters (if any) first.
You can do so manually if the module's content is rather short. A "&LT;" e.g. must be replaced by the character "<". You may also find a helper application doing that for you in one go.
I just tried a trick for you with one of my longer module (8K) using my browser and a interim text file. It worked. The browser interprets the escape codes and you can select the displayed text, copy it, and paste it into a plain text file. This will not re-escape the respective characters. Thus you can also paste this text into your new module in the Basic IDE, and it should work then...

emf wrote:Clearly OO does not open this file...
As I already told you: Only registered modules are used. There is a .xlb file which contains the little registry.
On Windows 10: LibreOffice 6.2 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2523
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Script cannot be found

Postby RoryOF » Fri Mar 08, 2019 2:19 pm

Is your script listed as some other entry under My Macros, perhaps something like "PasteUnformatted"?
Apache OpenOffice 4.1.6 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29432
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Script cannot be found

Postby emf » Sun Mar 10, 2019 12:48 am

Dear Lupp, thanks for your guidance.

Something has changed with OO. Copying the old file and pasting does not work first of all because it starts with:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">

This should be deleted, I suppose.
Then its the &quot; characters. (Unexpected symbol &) I suppose these can be replaced with " or as indicated, right?

I used the same file because I want to have all my macros together (there are half a dozen) but (I have made a secure copy of my original macros file to be on the safe side if something happens.

I have more questions, but let's move one step at a time. And I have to go over your first post again... But until now I did not have any problems with my macros.

BTW, I have redirected the user profile to a folder in MYStuff folder, making a change in the bootstrap.ini file. But I do not see any other problems with my profile except for my macros.

Thanks again. emf
OO 4.1.6 in 64 bit Windows 10
User avatar
emf
 
Posts: 79
Joined: Tue Aug 12, 2008 8:44 am
Location: New York

Re: Script cannot be found

Postby emf » Thu Mar 14, 2019 1:55 pm

OK, I begin to zero in on the issue. In my C drive I have 2 folders:

c:\My Stuff
c:\My Stuff 2

of which the second is an old bacup.
.
The OpenOffice profile is in a folder

..\Open(ffice\user\

in each of the 2 folders.

In the

C:\Program Files (x86)\OpenOffice 4\program\\bootstrap.ine

I have edited a line to

UserInstallation=file:///C:/MyStuf~1/OpenOffice

Up until recently, this directed to the My Sturr\OpenOffice.
A few days ago it started directing to My Stuff 2\OpenOffice.

It seems to be a windows issue. But does anybody here know How can I make it go to My Stuff\OpenOffice instead of to My Stuff 2 \OpenOffice ?
OO 4.1.6 in 64 bit Windows 10
User avatar
emf
 
Posts: 79
Joined: Tue Aug 12, 2008 8:44 am
Location: New York


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests