Create a new drawing and set the page size - google-apps-script

I use Google Drawings to annotate screenshots. Currently, my workflow is to create a new Drawing, and then set the page size via File > Page Setup > Custom.
Using the Google Apps Script, is there a way to automate this workflow? For example, I could create a simple UI, with two text boxes and a button. I enter width and height in the text boxes and then click the button to create the new Drawing.

You can create Files in DriveApp from a blob source using the .createFile() method.
One parameter in the blob object is MIME type, and there is a drawings option you can use. It doesn't look like you can pass size data into the file, though.

Related

Is there any way to change a Google Slides presentation without reloading it?

I'm basically trying to build a game board. For simplicity's sake, imagine a Jeopardy! board. I'd like to be able to click on a square (imagine it says $200) and go to the question set for that square. Then, when I return to the main board, I'd like that square that I clicked on ($200) to be blank, so I know I've already clicked it.
I want to be able to do this in a full screen presentation, without having to reload the slideshow at all.
I'm thinking, hoping, I could do a script that would just straight-up replace the image of a screen with text on it, to an image of a blank screen, but I'd also be okay with building the slide with two layers of images - one with text above one without - and deleting the top layer when it's clicked.
Click on and it becomes this:
Replacing the image via script can be easily done by using the following script:
function myFunction() {
var image = SlidesApp.getActivePresentation().getSlides()[0].getImages()[0];
// Get the Drive image file with the given ID.
var driveImage = DriveApp.getFileById('File ID of the new image');
image.replace(driveImage);
}
But unfortunately, assigning an image to act as a button to run script is only available on Google Spreadsheet. And by further checking it seems somebody already submitted a Feature Request for such a feature to be implemented on Google Slides as well.
References:
https://developers.google.com/apps-script/reference/slides/image#replace(BlobSource)

AppsScript with Google Sheets: Conditionally load images based on user interaction/when a range is selected

We've got a google sheet with user editable text that will eventually be used within images. We have a web application that generates the images and serves them, so they can be embedded within the IMAGE function provided within Sheets.
This works fine and ends up being something like:
=IMAGE(CONCAT("PREVIEW_TOOL_URL", "?t=", ENCODEURL(previewText(D2))), 3) where 'previewText' is simply formatting the string to pass to the web tool.
However, to avoid overloading the server and generating a ton of requests every single time someone loads the sheet, I'd like to make it so images only load in some condition (i.e. a user presses a button or they highlight the text), is there some way of doing this?
Add a checkbox to E2:
=IF(E2,IMAGE(CONCAT("PREVIEW_TOOL_URL", "?t=", ENCODEURL(previewText(D2))), 3),"Check to preview")
You can also use Apps Script for this!
You will have to start by:
Go to Tools > Create a new script;
Use the following script:
function loadImages() {
let sheet = SpreadsheetApp.openById("SPREADSHEET_ID").getSheetByName("SHEET_NAME");
sheet.getRange("CELL_YOU_WANT_TO_PLACE_THE_FORMULA").setFormula("YOUR_FORMULA");
}
Do not forget to adjust this script such that it meets your needs accordingly.
Insert a new drawing into the sheet;
Attach a script to it by going to the three dots symbol on the drawing; when asked about the name, input loadImages which is the function which we had created previously.
Press the button on the sheet and that's it!
Reference
setFormula(formula).

MS Access Form from Paper Form

I have taken over an MS Access database that was created by an employee that has moved on. It appears that he has created a form in the database by importing a paper form that is used within our company. What makes me believe that he imported a paper form is the exactness of Access form in relation to the paper form.
I am not sure how to ask query this using Google nor Bing. Can someone point me in the right direction on how to do this, please? I need to do the same thing with another paper form.
Yes, June7 is right, this is a handy technique.
Scan your paper document as JPG or PNG
Create a blank Access Form, and from the Design ribbon menu, choose "Insert Image" and select your newly created JPG or PNG scan
For the image object, check the properties window and make sure the "Sizing Mode" is set to Clip (and not Stretch or Zoom)
Now re-size the Image on your form so you can see everything correctly.
Now add Text boxes on top of the image, to create fillable text fields, exactly over the same place as the ones in the scanned image behind your text boxes.
You can then make a Table with the same field names, and update the Form to use this Table as it's Data Source on the Data Tab of the Form properties.
Once you have the form working perfectly nicely,
a handy time-staving step is File -> Save Object As -> change the Form dropdown to Report
Now you have created a Report that is printable using the same data table you created earlier (and write macro or VBA code make sure you print only one record at a time if that is the normal behaviour you expect)

Way to create file with the box api

I there a way to create a doc, like a .boxnote into a third app with the box api ? It seems that only edit, delete update functionalities are avaible.
I would say that it is not possible.
Box Notes are created using an specific web application from Box. But Box's API only have two modules :
Box Content: for managing the upload/download of data
Box View: for converting docs to HTML

how to save a text file automatically in flex when the text area is changed/edited. please help me

I had a situation like.... I need to save a text area field in the form of .text file automatically when ever the text area is changed/edited. Please some one help me.
Thanks in advance
In a Flex TextInput or TextArea you can use the change event to detect when something has changed. So, you'll probably want to use that to trigger your "save this text" code.
If you want to save things as a file on the server, then you can use that change event to trigger your service.
If you want to save things on the client machine, you may have more difficulty.
If you're dealing with an AIR application, you can save the file locally using the File class.
In a browser based app; you cannot save files without user input. So the location, and filename of the file is beyond your control. Accessing that file at some future point also requires user input.
You may be able to store the value as a shared object, which is in essence the Flex version of a cookie.