Using Cookies from inside Excel

I’ve been looking at how to use cookies to pass data between excel sessions and of course outside Excel. Having implemented a method of hiding data inside cells and Excel shapes, I figured this would be a nice next step.

After a few missteps, I eventually got it to work. See the cookies tab of Hiding data in Excel Objects and JSON serialization
Essentially, these are the steps in VBA
  1. Generate an .html file that can read or write cookies, and generate the data required to be stored as part of the javascript.
  2. Create a cookie into which the contents of the cookie are populated by the generated javascript
  3. Read the appropriate element of the document to find the contents of the cookie.

In the cookie I store JSON formatted data. This means that it carries its own definition and can be used directly by other Javascripts.

I hit a few snags along the way that were related to being able to run local scripts with active content, but i came across something called ‘mark of the web’, which seems to trick the browsers I’ve tried into being able to run it. I’ll be writing this up on web site shortly so you can read all about it there
About brucemcp 225 Articles
I am a Google Developer Expert and decided to investigate Google Apps Script in my spare time. The more I investigated the more content I created so this site is extremely rich. Now, in 2019, a lot of things have disappeared or don’t work anymore due to Google having retired some stuff. I am however leaving things as is and where I came across some deprecated stuff, I have indicated it. I decided to write a book about it and to also create videos to teach developers who want to learn Google Apps Script. If you find the material contained in this site useful, you can support me by buying my books and or videos.

1 Comment

Comments are closed.