Bound script breaking when file it's bound to is copied - google-apps-script

I have two bound scripts in a template I am replicating hundreds of times. The scripts are easy and small. They work fine in the initial template, but when I copy the file dozens/hundreds of times, it breaks 50% of the time and I get this error when I try to run them from the new file:
Server error occurred. Please try saving the project again. (line 0).
Saving the project again isn't working.
Why does my script break when I right click/make a copy of a Google Sheets, and how I can stop it?

Related

Octave pop up message

I am running Octave 4.4.1 on MacOs Catalina 10.15.7. For some weeks I have been having this message poping up when a code is running: "
It seems that [name of script] has been modified by another application. DO you want to reload it?
I click Yes each time it pops up, but when the code is running, it just keeps coming back, and sometimes Octave becomes unresponsive although the script has finished running
All I could find on the internet were either some old posts with answers about outdated Octave versions, or very complicated stuff that I would not be able to implement.
Any one knows why this happens, and what to do about it?
thanks a lot
This message is exclusive to the GUI version of Octave, and it comes up if you have a file open for editing in the Octave GUI Editor window, and the file's contents change due to a process unrelated to the Octave Editor.
E.g. you may also be editing the file on an external text editor at the same time? Or your script may be copying / generating a new file under the same name as a file that you've got open in the editor, effectively overwriting the now-out-of-date version that's still being displayed in the Octave Editor?
Octave gives you this warning to prevent you from 'saving' in your editor, and therefore undoing any changes that had been made by the external process in the meantime.

Server-error when DriveApp.getFolderById try to get (bigger) folder

I'm automating folder-creation for both projets and customers. The customer-folder has ~400 sub-folders and throws the same error. Exception: a servererror occured. wait and try again later (translated)
function test () {
DriveApp.getFolderById("28letterFolderIdxxxxxxxxxxxx")
}
The Apps Script is unable to access the main folder. It fails before doing anything fancy. I've tried multiple account; incl. owner.
I did a migrate a few folders (many hours prior) but are now starting to suspect that it's the size (360+ subfolder) that is the problem.
Drive-api works fine (get folder)
Same function (copy/paste) works in new script-file
Can script-files get corrupted? I rather not remake it, as it's a library, in use.
Solution: Script had a connected GCP-project where the Drive-scope hadn't been added. It also needed to be reinstalled.

Cozyroc MailTask script not working

I am trying to use CozyRoc's script to perform mail server tasks like moving emails from one mail folder to another. I am using the script found here:
CozyRoc Mailtask Script
So far it doesn't work. The error i get is that my connection manager is not found, which makes no sense. In a different package I have set up a fetch mail attachments process with success, so my connection is tested and working. Anyone used it before with success?
Creating a new project from scratch with the exact same setup i used in the previous one solved the problem. I was unable to figure out why, but this solved the problem.

Octave error : no such file

I'm running Octave 4.0.1 on windows 7 and I'm having this weird issue.
I created a functioning script which is saved under C:/User/Documents/Octave. This script also reads some files in a subfolder of this same location.
The problem is : my script correctly runs TWICE then I have the error "no such file" saying the software did not find my script (the same one I just ran). The only "solution" I have is restarting the whole software but then it still goes nuts on the third run.
In addition to that, my coworker tried it on an ubuntu machine and it seemed to work fine. Do somebody see an explanation?
Thanks
Here is the script :
data = [];
figure();
for i=1:200
filename = strcat('C:/Users/Utilisateur/Documents/Octave/data/DAQ_data_decoded_', num2str(1800+i))
d=lvm_import(filename);
data=[data d.Segment1.data(:,2)];
end;
data=reshape(data,6600,1);
hist(data);
The function lvm_import is a function I found on the web to extract data from a Labview data file. (d.Segment1.data(:,2) is a 33x1 array)
And the error message :
>> daqDataHist
error: no such file, 'C:\Users\Utilisateur\Documents\Octave\daqDataHist.m'
So I still don't really know what was going on but by adding fclose all at the end of the script I got rid of any error and can run the file as many times as I want. It was probably something going wrong with opening and closing the .lvm files and it "jammed" at some point.
Thanks anyway :)

How to close ONLY the instance of Excel that was opened by OLEFormat.Activate

Ok, I'm creating a Word document (based on a template) from MS Access and updating several charts by using the OLEFormat object. Once I .Activate the object, which creates a new instance of Excel, and make my edits, I close that instance of Excel with:
wdChart.ChartData.Workbook.Application.Quit
This works fine if there are no other instances of Excel running. But, if there is an open instance of Excel when the OLEFormat.Activate happens, it doesn't create a new instance of Excel, but opens the chart spreadsheet in the same instance of Excel that is open. So when I execute the .Application.Quit command, it closes ALL open workbooks in that instance and prompts me to save the workbook. At this point, I get a Word message that says:
To insert a chart, you must first close any open dialog boxes or
cancel editing mode in Microsoft Excel
The my code fails with a:
Method 'Activate' of object 'ChartData' failed
I think these errors have to do with the fact that my code is sequentially editing several charts. When the Word dialog pops up, my code is still trying to run or something.
I think what would solve all of this is if there is a way to force the OLEFormat.Activate to open it's own instance of Excel. Is this possible?
You need to check to see if there are more than 1 workbooks open. If so, then close the chart workbook, otherwise, quit the application.
If wdChart.ChartData.Workbook.Application.Workbooks.Count > 1 Then
wdChart.ChartData.Workbook.Close saveChanges:=False
Else
wdChart.ChartData.Workbook.Application.Quit
End If
I had a similar issue with this and with "AddChart", for some reason in Office 2010(not 2013 or 2016) sometimes when accessing multiple charts in a row the excel windows doesn't close before another one opens. This causes the error that #MultiGuy experienced.
I my case I just added a small wait time in front of my "Activate" and "AddChart" calls and it seems to have resolved the issue:
Excel.Application.Wait Now + TimeValue("0:00:01")
Long term I should probably write some sort of function that waits until the associated excel window has closed, but for now I think this much more brittle approach will work in most scenario's.