Persisting VBA/VBScript macro settings - vba

I've created an Outlook (2010) VBScript macro that has some user-configurable settings. I've googled and checked the likely resources and can't figure out a good way to persist them. I'm currently storing them in the body of a mail item! It don't get much kludgier than that!
Should I use the Windows registry? An ini file? Or??? And whether registry, file, or???, what key/folder/??? would I use?

Just before hitting 'Post' on this I tried one more google search and hit on this: http://www.jkp-ads.com/articles/DistributeMacro08.asp.
The gist I took away was, ini file or registry are both kosher. One nice thing about VBA's use of the registry is it automatically puts "app" data in the approved place, just need to give your "app" a key. Since my data is just a big string with parsing code already in place, I used strData = GetSetting(strAppKey, strSection, strLeafKey) and SaveSetting(strAppKey, strSection, strLeafKey, strData) and voila, all is good.

The standard Outlook way of storing settings, especially if they relate to a particular mailbox/store and can be accessed from multiple machines connected to the same mailbox, is to use a hidden message stored in one of the well known folders, such as the Inbox.
The hidden MAPI messages can be accessed using MAPIFolder.GetStorage: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mapifolder.getstorage.aspx

Related

How to go to a folder without specify the path

I am creating a button that will open one directory in your computer (for example: C:\Users\NameOfUser\Downloads) when you click it. But if I do this on another computer or from another user account with a different name the button doesn’t work. I just used Process.Start() for the button.
Is there a different way to do this that will work from any user account?
You can get most folder paths like this just by calling Environment.GetFolderPath() with the right Environment.SpecialFolder enum value. Unfortunately, the Downloads special folder in .Net isn't quite "special" enough and (imo) is unreasonably complicated to get. If you actually need to know the path, the correct way is to follow the accepted answer here:
Getting Downloads Folder in C#?
Even worse, it's written for C# and uses code that's not very easy to translate.
The good news is there's also a NuGet package I'd expect you can use from VB. The even better news is you don't really care about the exact path in this case. You just want to open an Explorer window via Process.Start(). That means you can use this shortcut (also available via the other question):
Process.Start("shell:Downloads")

XPages POI4Xpages download to network location

Using POI4Xpages which is great LINK
However, I was wondering, at present, when it creates my word document, it simply downloads, like a normal download from the internet, storing it the downloads folder in windows (using Chrome anyways)
Is there a way, using POI4XPages, to instead, dump the file to a specified network location, for example a shared drive?
After that, I would simply build a link to the file using the network location, and a filename variable for example to pick the correct file.
If thats not possible, is it possible to get a handle on the file before or after it is downloaded, and then save it to a field in the xpage?
In short, I want to avoid the user downloading the file, then having to attach it manually to the xpage.
Thanks
POI allows you to get a handle to the file using the variable "workbook". You are also able to provide the specific downloadFileName you wish to use. Using the postGenerationProcess property you should be able to make a call to a Java method that makes the connection to your network drive where you can use the "workbook" variable and downloadFileName value to save your document. If this doesn't work definitely post a question on their project site because the creator does reply.

Sandboxed Applications, Where to Save Files Without User Interaction

I'm a bit confused about where the application should send a bunch of files. Let me suppose that an application accepts a number of images with NSOpenPanel at a time from the user. The application applies graphic filters to them. And it's now ready to save processed files. Before they forced us to sandbox applications, we were allowed to export processed files to application folder in Application Support without NSSavePanel. If you wanted to save files elsewhere, then you had to use NSSavePanel. If the application is sandboxed, it cannot send files to NSApplicationSupportDirectory/{app name}(which points to the containers folder assigned to this application)? My first sandboxed application was rejected a few days ago merely because a text field showed a path to container's application support folder. So if you have a bunch of files to export, you have to prompt the user to ask where to save each file? AppSandboxDesignedGuide, which Apple, Inc. has issued, has nothing to say exactly about where to save files except that it says "Your app has unrestricted read/write access to the container and its subdirectories." I think this PDF guide is a printed version of this web site. I'm asking this question here because I have some doubts and reviewers were often wrong at least when I submitted applications to them two years ago.
Thank you for your advice.
If the files are only for the application itself to use you can save the files in "Application Support/", which under the sandbox is under your container, just as before - just use the APIs to construct the path to that folder (and create it, it doesn't exist automatically, just as before).
If you are outputting files for the user to access then you don't put them in the container - that folder is meant to be hidden from ordinary users, though yours is the first time I've heard that even showing the path got you a rejection, but Apple are pretty random.
Here are three choices of where to put your files:
First is to ask the user. This is what you would normally do anyway, you shouldn't just dump files somewhere.
Second is a situation that the sandbox makes harder - when where the file should is is implicit, e.g. a graphic conversion program might sensibly output the converted file with the same name but different extension in the same folder as the original. This was finally addressed by Apple around 10.8.3 or something with "Related Items" - Apple's docs for this are here. Essentially in the Document Types in the Info.plist you must list all the extensions you handle - both in and out - and add a NSIsRelatedItemType key with the value of YES to all those you might convert between. E.g. For TextEdit .rtf, .rtfd and .txt are flagged in this way so TextEdit can open as one format and save as another.
Third, if you wish to put all your files in one location, say in a "Converted Items" folder. Then you ask the user once to specify this folder and then save a security-scoped bookmark to that folder in your applications defaults or elsewhere in your app's container. On subsequent executions you can access this bookmark and regain access to the folder. For an introduction to this start with Apple's Security-Scoped Bookmarks and Persistent Resource Access. This is really no harder than pre-sandbox as any decent app would always ask for the location of the folder from the user, the difference is the need to save the security-scoped bookmark so the user doesn't need to give permission every time.
HTH.

Externally triggering Thunderbird into displaying a wanted message

I would like having a way to trigger Thunderbird, from an external script, into displaying a particular message in a particular folder.
If it were Firefox, say, I would use firefox -new-tab http://some-URL, and an already running Firefox (or a new one if none) would nicely fetch and display URL. But I found no way to do something equivalent with Thunderbird, neither on the Thunderbird site or through existing extensions, and even after some furious Googling around, which I attempted more than once!
One problem, compared to a plain URL, is the need some notation for selecting a message. Short of a better solution, I wrote a script which knows folder:SOME-FOLDER:ORDINAL, and behaves like an extension of xdg-open. My tool inserts a proper prefix and a few .sbd as needed within the SOME-FOLDER part to turn it into an absolute Thunderbird file reference, and ORDINAL picks a message in that folder. My tool then grabs the message, heuristically converts it into HTML file, and then, directs a Web browser to the resulting file (and if :ORDINAL is not given, it processes the whole folder instead, yielding an HTML index and many linked messages).
My current tool helps a bit at saving message references in other documents and efficiently retrieving them later, but I handle a copy of the Thunderbird message, and not the original. So if I want to delete it, refile it in another Thunderbird folder, and do other similar operation, I still have to go to Thunderbird, interactively find my way again to the wanted message before I can handle it, and this, is not efficient. What I'm dreaming of is a way to get rid of all my HTML conversion and browser trickery, but still keep the pseudo-URL paradigm and pseudo xdg-open interface, to directly force Thunderbird into the correct folder, with the wanted message correctly displayed.
In previous email readers I used (Emacs RMAIL and then Gnus, and Mutt as well later), such things could be managed, and I heavily used such capabilities in scripts. I am astonished, surprised, even a bit dismayed, by the apparent weakness of Thunderbird as a scriptable mail reader. Am I missing something evident? Any avenue or suggestion?
François
P.S. Of course, I agree that using ORDINAL is not very clever. It might mean a different message if the folder get some messages added or deleted. This is a lesser bad. A better but potentially heavier notation might use Message-ID values, but then, an index would also be needed to find the Thunderbird folder containing each message.
There seems to be some way to do it since Google Desktop supported it according to this thread - http://forums.mozillazine.org/viewtopic.php?f=39&t=584542. Perhaps try installing Google Desktop and see what kind of hyperlink its using?
I'll add Outlook supports using external hyperlinks using the outlook: naming scheme, for example outlook:Inbox or outlook:0000000007A2379547B0624691F4FB2E5468A0D7642E2000. See http://www.davidtan.org/create-hyperlinks-to-outlook-messages-folders-contacts-events/ for more info.

Saving program shared data in Exchange Public Folder

I have a question reffering to Public Folders on Exchange Server.
I have an application (Outlook Com Addin) that need to share settings amonge every Exchange User that have access to Public Folders.
I was thinking about storing settings in MAPI assotiated message (hidden MAPI message). Wirting\Reading data from this message works fine, but I don't have good place to save this item.
I am looking from some sort of global folder or root folder that every user have. I tried All Public Folders folder, but noone can store any item there. I was also thinking about NON_IPM_SUBTREE but I am not sure which folder can be used to write there something.
Maybe someone faced this problem already and have some thoughts about this it?
And to make things clear. I am using Extended MAPI, but if you know any solution that involves Outlook API, I would be interested in that too.
Best regards,
There are no predefined PF folders. Most installations will have "Outlook Security Settings", but that is about it.
There is also a set of hidden folders where Outlook stores f/b info.
Keep in mind that PF is optional as of Exchange 2007. Exchange 2010 does not install PF store by default.