I am currently working on a Excel Javascript Add-In that is supposed to go through an extremely big amount of Data to take a value from one column, seperate it into certain strings and paste those strings into seperate columns.
My problem is with accessing the value of the cell.
I am using the standard procedure (see below) which is also used in the sample code given by Visual Studio (Community 2017).
When I print all the possible properties of the given cell into the console, some have a note next to them that says: "" which is German for ""
Therefore I can´t access these properties and not get any result for the "value" property.
The strange thing is that the same code already worked in another project and therefore another project.
The code is basically
var sheet = context.workbook.worksheets.getActiveSheet();
var range = sheet.getRange("C1:C1").load("values,text");
var value = range.values[0][0];
The property notes:
I received the following error code:
Error: PropertyNotLoaded: The property 'values' is not available. Before reading the property's value, call the load method on the containing object and call "context.sync()" on the associated request context.
I searched the internet a lot and tried to find an awnser but I couldn´t find anything. I hope you guys can help me.
Thank you very much!
Related
I have an Acrobat .pdf document which includes a Javascript global variable. I am trying to get code in VBA that will reference the value of this global from Acrobat, but I can't quite figure out the necessary syntax to do so. I assume that this is a trivially simple question, but nonetheless it has me stumped.
Basically, in my Acrobat/.pdf document, I have some very simple Javascript that defines:
global.ReturnString = "Arbitrary String";
and then I have another very simple button that displays that return string as an app alert:
app.alert(global.ReturnString);
All I want to do is to be able to reproduce this extremely simple functionality via an Excel message box. In other words I just want to write some working VBA code that will successfully execute this in Excel:
MsgBox (SomeSortOfPointerToAcrobat.Global.ReturnString)
So far I haven't been able to get this to work. I've tried using GetJSObject as the construct to pass info between Acrobat and Excel (VBA code below). I am currently opening the .pdf file in an Excel userform at the time that I am trying to reference the JavaScript global variable in Excel VBA:
Dim gAPP As Acrobat.CAcroApp
Dim gPDDOC As Acrobat.CAcroPDDoc
Dim jso As Object
Set gAPP = CreateObject("AcroExch.App")
Set gPDDOC = CreateObject("AcroExch.PDDoc")
If gPDDOC.Open("C:\path\testdoc.pdf") Then
Set jso= gPDDOC.GetJSObject
MsgBox (jso.Global.ReturnString)
End If
But this always leads to run-time error '438': Object doesn't support this property or method.
I have the Adobe Acrobat 10.0 Type Library added to my VBA project.
Any suggestions?
Again, I apologize for what I assume is a very trivial question. I'm happy to clarify as needed for any needed details that I've left out of this description of the question.
(Marking as answered so that this no longer shows as an open question)
ANSWER: Code was, in fact, correct as-is in the original question.
I'm trying to make a Google sheet fetch actuarial data from another sheet; the other sheet essentially acts as a look-up table. The code (with the spreadsheet id removed):
function deathProb(age,sex) {
return SpreadsheetApp.openById("<spreadsheet id>").getActiveSheet().getRange(age,sex,1,1).getValue();
};
It should be really simple, and it worked earlier this year, but about a month ago it stopped working and now when I debug it gives the error:
Cannot find method getRange((class),(class),number,number). (line 3, file "").
In the sheet itself, it gives the error "You do not have permission to perform that action (line 3)".
If I change the code to "...getRange(5,5,1,1)...", so that it doesn't use the variables "age" and "sex", then it doesn't give the error in the debugger but in the sheet itself it still gives a "You do not have permission" error. I looked around and found that triggers can cause this problem, so I added a trigger like this:
[X] deathProb From spreadsheet On edit"
and authorized the script to access the other spreadsheet, but that didn't solve either problem. Any ideas?
You are probably using this script as a custom function ?
If so, this error is due to a change Google recently rolled out prohibiting the use of SpreadsheetApp.openByUrl(), SpreadsheetApp.openById(), etc.. in custom functions.
You can still use this method from other contexts like a menu item, trigger, etc. Google had to roll out this change for security reasons and they won't be able to revert back to the old behavior.
The issue is listed in the issue tracker: see here.
I'm trying to get MonkeyTalk working with Javascript. I'm automating some tests with iOS. When I run the .MT version, the test runs fine. But, the Javascript version errors with this.
ERROR sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot find function uISearchBarTextField. (RADialerDirectory.js#8) in RADialerDirectory.js at line number 8
The export javascript code shows this:
this.app.uISearchBarTextField().tap();
Anyone know how to get around this error? I'm just trying to use the Javascript version of the script to loop and later grab external data to iterate through.
I had the same problem for "UIAleartView". There are three ways to get it work. this happen because MonkeyTalkAPI.js file doesn't contain an entry for "uISearchBarTextField"
Use more generic type(Input) like above answer.
Set accessibilityLabel property of that component and use it as a monkeyID like here: MonkeyTalk : Verify custom UITableViewCell Label text without select the cell
A little hack to MonkeyTalkAPI.js class. find the word for "Input" which is more generic to your "uISearchBarTextField" and get a copy of it paste it again in that file and edit replaceing "Input" with "uISearchBarTextField" save it and run. if you did it carefully it works.
Happy Testting
I am navigating an object that contains an array of objects.
When I use chrome's js developer console I can grab the title property from the first item in the array i.e.
hello.example.array[0].title
this returns the title (only in the js developer console). However when I write a script to do this for me suddenly I receive this response:
Cannot read property 'array' of undefined
here is an example of my js
var theTitle = hello.example.array[0].title;
console.log(theTitle);
Why does the console find it correctly when my js does not?
Try selecting the expression in question in the script view and then use the Ctrl-Shift-E shortcut to evaluate in the console. Or, copy-and-paste from the script view into the console. Or, hover over the last component of the expression in the script view to see the value. In either case, you will most likely find that you've mistyped something, or are executing the script in a different context than that in which you are evaluating the expression in the console, etc.
Thanks to #Barmar, I realized I needed to view how I was going about grabbing the 'title' property.
My solution was in the context of other code and how the object was being created in the first place.
Thanks all for the help!
Edit 6 Years later:
This post has some popularity so I thought I would update it with a more valid answer...
Make sure your JavaScript actually has the scope/context of the object to begin with.
The JS Console is able to return it because it is being executed after the code has run.. whereas the JavaScript in question might be trying to access the variable before it is set.
So check if you have the right scope/context and that the code is not trying to access a variable before it has been set.
I wrote an HTA that reads information out of a bunch of text files and displays the results to the screen using the following pseudo-logic:
loop through a directory and add the content of each text file to an array
loop through the array's 2 dimensional structure to build a table layout
update itself using a setInterval timer
I originally wrote it in purely vbscript/HTML which worked perfectly but then I needed a way to sort the displayed results by the third column or the array[x][2] value.
So I turned to javascript as it has much more friendly/quicker array usage. I rewrote the functions so that the pseudo-logic looks like:
loop through a directory and add the content of each text file to a JAVASCRIPT array
SORT the JAVASCRIPT array by the array[x][2] idx
Flatten the 2D JS array into a string using separators
Split the sorted JS string into a VBS array and build table layout the exact same way
update self using setInterval timer
after working out the syntax errors, the initial HTA load works perfectly as I'd intended it to. But now, upon the setInterval() update, I get a generic JS error:
Line: 1
Char: 1
Error: Object doesn't support this property or method
Code: 0
URL: file:///pathToHTA.hta
I've gone so far as to comment out the entire update function I'm using with setInterval() so that the function gets called but it doesn't actually do anything and I STILL get the error.
I'm at a loss as to where to go from here and am hoping someone might be able to give me some pointers as to what might be causing this error. Thanks in advance.
So I found the problem:
For whatever reason, I had to switch the order of my script declarations. In the original one with errors I was declaring my scripting in this order:
<script type="text/javascript">
...
</script>
<script type="text/vbscript">
...
</script>
The fix was that (for whatever reason), I had to flip-flop the delcarations.
I changed the order so that my vbscript functions were listed first and javascript ones second and this resolved the error.... anyone know why that would be?