Trying to save open MS Access documents from JScript - javascript

I was hoping to save all open MS Access documents via a JScript run from the Windows Script Host.
So far I was able to obtain the MS Access object by calling:
var objAccess = GetObject('', "Access.Application");
But now I'm stumped. If it was MS Word, I'd enumerate all open documents in the .Documents property and call Documents.Item(n).SaveAs() method on each of them.
But how do you save-as all open documents in MS Access?

After you have your object variable set to an Access application instance with GetObject, use its Quit method with the acQuitSaveAll option (value = 1). Not sure about JScript; in VBScript, I can do it like this.
Dim objAccess
Set objAccess = GetObject(,"Access.Application")
WScript.Echo objAccess.CurrentDb.Name
objAccess.Quit(1) ' acQuitSaveAll
Set objAccess = Nothing
Note, when I used GetObject as in your example, objAccess was a new Access application instance rather than a reference to the instance which was running previously. So, with the GetObject line like this ...
Set objAccess = GetObject('', "Access.Application")
... the WScript.Echo line threw an error with CurrentDb.Name (because there was not a database open in that Access application instance.
This approach will save any changes to database objects (tables, forms, reports, etc.) which were in design mode but not saved. However if a user has any unsaved changes to data in a form, those changes will be discarded despite the acQuitSaveAll option. It seems that option only applies to objects, not data.
Edit: If that approach is not satisfactory, you can do something more sophisticated with VBA in your Access applications, as #Remou mentioned in his comment. An example is KickEmOff from Arvin Meyer. He also offers a sample database which demonstrates that code in action.
Edit2: Remou's comment got me thinking acQuitSaveNone (value = 2) should be safer than acQuitSaveAll ... the unsaved object changes would be discarded, but at least you would be less likely to save an object in a non-functional state.

Related

(JavaScript API 1.3 for Office) Set Value of Custom Properties

My client has decided to migrate to Office 2016 and porting portions of a business process to that client requires us to offer a replacement to the Document Information Panel, which is no longer available. The Backstage file information area isn't considered a sufficient user experience for the users in question, so we're endeavoring to replace the DIP with a Task Pane app.
This example: https://www.youtube.com/watch?v=LVGqpns0oT8&feature=share shows that the idea is, at least in theory, possible. We considered buying this app but can't find sufficient information to do so.
So we set about attempting to replicate the functionality we need in the DIP. It appears that we can successfully set Document Properties of standard types, such as strings, which looks something like this:
Word.context.run(function(context){
var properties = context.document.properties;
context.load(properties):
return context.sync().then(function(){
properties.title = properties.title + " Additional Title Text"; // once the sync goes off, this works.
return context.sync();
});
});
However, when we try to update an Document Property that's, for example, a Managed Metadata property defined by a SharePoint content type, the value in the proxy object loads and remains changed, but it seems to break its relationship to the actual document property. The code below demonstrates:
Word.context.run(function(context){
var properties = context.document.properties;
var customProperties = properties.customProperties;
context.load(properties):
context.load(customProperties);
return context.sync().then(function(){
var managedMetadataProperty = customProperties.getItem('MngdMetadata');
properties.title = properties.title + " Additional Title Text"; // once the sync goes off, this works.
context.load(managedMetadataProperty);
return context.sync().then(function(){
console.log(managedMetadataProperty.value) // let's say this looks like "10;#Label 1|64d2cd3d-57d4-4c23-9603-866d54ee74f1"
managedMetadataProperty.value = "11;#Label 2|cc3d57d4-4c23-72d4-3031-238b9100f52g"
return context.sync(); // now the value in the javascript object for managedMetadataProperty is updated, but the value in the document does not change.
});
});
});
The document property Managed Metadata Property never changes in the Word UI, nor does a change push back to the SharePoint. Say we save and close the document after making the update, then re-open it. The Property value has not visibly changed, however when we load the proxy object with 'context.load()', the value that's available reflects the changes we made on last run.
I'm unclear about why this would be. It seems like to circumvent this, I would need to make a call back to SharePoint to update the relevant field, but I don't know how I would instruct Word to refresh with the new information from SharePoint.
That's a great question.
The custom properties API gives you access to some built-in properties as well as custom properties. SP-related properties do NOT follow in this category from the API perspective. (and the same is true in VBA/VSTO/COM) To access those you need to use the CustomXmlParts functionalities. Here is a good example on how to use it in the Javascript API.
Also, FYI, the team is working right now in a feature to enable the DIP again, i don't have concrete dates or commitment, but you might get this functionality again out of the box soon.
Have you tried customPropertyCollectionObject.add(key, value) ?
It will replace existing kvp's in the customPropertiesCollectionObject.
Here is the documentation customPropertiesCollection

Some SiteCatalyst eVar values not passing in Custom Link

I'm facing a crazy matter with a SiteCatalyst Custom Link (internal) request.I'm firing an s.tl() through the code below:
var s_custom = s_gi("report-suite");
s_custom.linkTrackVars = "eVar76,events,list3";
s_custom.linkTrackEvents = "event87";
s_custom.events = "event87";
s_custom.eVar76 = "value";
s_custom.list3 = "option1,option2";
s_custom.tl(this, 'o', 'link name');
The issue concerns the eVar76, whose value is not included in the request, even if the "s_custom" TrackerObject contains it. In fact, if I inspect that object I find it.This strange seems to affect just "high" number eVars, like eVar76, 77, 80, 99 and so on, not lower ones.Replacing eVar76 with eVar55, 56 or 60, for ex, is resulting in a normale behaviour where values are normally included in requests.This is not depending on eVars existance, or activation, in the report suite and this is expected because no preliminar calls are made to Adobe server in order to check the set, or enabled, eVars in that report suite.This is a very silly behaviour forcing me to replace the desired eVar with another one.I just add that this Custom Link is prepared by a Page-load (DOM ready) rule in the Adobe DTM, but I suppose that no particular setting should be done in order to fix it.This is the first time that an SC variable is not included in request as expected.Thanks so much for supporting me.
The core Adobe Analytics library code builds the request string with a loop that looks for events/eVars up to the max available. Adobe Analytics only recently expanded events from 100 to 1000 and eVars from 75 to 100/250, so in order to accommodate this increase, an update to the core AppMeasurement library code was made.
Note: Although Adobe has been making updates to the Legacy H library alongside AppMeasurement, they did not update the Legacy H library to accommodate this increase. So, in order to track eVar76+ and event101+ within javascript as the variable (e.g. s.eVar76='foobar'), you must upgrade to the latest AppMeasurement library.
Alternatively, if you are using Legacy H.23+ library you can instead populate it as a contextData variable and then map it to the event/eVar/prop in a processing rule (e.g. s.contextData['eVar76']='foobar' and then in processing rule you'd have e.g. if [(contextdata) eVar76] [is set] then overwrite [eVar76] with [(contextdata) eVar76])
Reference: https://marketing.adobe.com/resources/help/en_US/sc/implement/evars_events.html

Setting a new property to PFObject

I have a Parse.com cloud function that sends back a PFObject. In some cases I need to send back values for keys that don't exist in the PFObject. Is that possible?
This is what I tried:
var test = prodAndTitles["products"][0];
test["XOXO"] = "kisses";
prodAndTitles["products"][0] = test;
console.log("XOXO = " + prodAndTitles["products"][0]["XOXO"]);
This prints out kisses as expected.
But back in the app when I try to get the XOXO key it's not there:
NSLog(#"The product's XOXO %#", [self.product objectForKey:#"XOXO"]);
This prints out null.
I also tried changing the product type from PFObject to id, but it doesn't help.
Is there a solution, without going into the datastore class and creating dummy columns?
Here's a complete answer to the problem I faced:
The issue is that none of the notations above works for the Parse.com backbone javascript objects that come from the datastore. This is the notation that does work:
testObject.set('TestProp', 'TestValue');
But this is still only part of the solution. When trying to send the testObject with the newly set property to the client ios app, it causes an error:
Uncaught Tried to save an object with a pointer to a new, unsaved object.
The solution for this is to save the testObject after setting the property:
testObject.save();
This doesn't really make sense because I would have liked to add properties to the testObject and NOT save them to the datastore -- and it's a waste of a database call -- but it seems like Parse won't allow it. Weird.
This is done with setting the correct ACL. The ACL has to be set for the user to be able to read and write. Then you can add new columns. In Cocoa it looks something like this:
PFACL *acl = [PFACL ACL];
[acl setReadAccess:YES forUser:[PFUser currentUser]];
[acl setWriteAccess:YES forUser:[PFUser currentUser]];
[test setACL:acl];

Client side routing. How does it work?

I need a client-side routing solution to work with a chrome app. I've researched several and crossroads.js seems like a good fit. When I include it in my html file, it doesn't seem to work; that is, if I use code like
crossroads.addRoute('/news/{id}', function(id){
alert(id);
});
crossroads.parse('/news/123');
, the page alerts '123' but if I type '/news/321' in the browser's url bar, it preforms the browser's default action, instead of alerting '321'. What am I doing wrong. (Also, I realize the title is broad, but I believe the difficulties I'm having with crossroads.js are more general than crossroads.js in particular. It is given as an example.)
Use Hasher (by the same author) also.
The documentation on the Crossroads page tells you that you need to use Hasher, (because that will be used for monitoring the widow.location bar.).
So you would also need to use Hasher, and initialise it, then you can add your "Crossroads" routes to Hasher to start monitoring for those particular routes.
//setup crossroads
crossroads.addRoute('foo');
crossroads.addRoute('lorem/ipsum');
crossroads.routed.add(console.log, console); //log all routes
//setup hasher
hasher.initialized.add(crossroads.parse, crossroads); //parse initial hash
hasher.changed.add(crossroads.parse, crossroads); //parse hash changes
hasher.init(); //start listening for history change
//update URL fragment generating new history record
hasher.setHash('lorem/ipsum');
http://millermedeiros.github.com/crossroads.js/
The command parse tells crossroads to have a look at the string and do an action based on it.
So in the case of crossroads.parse('/news/123'); it will always use /news/123.
Since you want crossroads to parse what you have in the browser address bar, you'll need to use that value in the parse method:
crossroads.parse(document.location.pathname);

How can we identify a unique nsHTTPChannel?

I am doing some development on the firefox both with javascript and C++ for some XPCOM components.
I am trying to monitor the http activity with nsIHttpActivityDistributor.
The problem now is , is there any flag or id that belong to nsIHttpChannel that I can use to identify a unique nsHttpChannel object?
I want to save some nsIHttpChannel referred objects in C++ and then process later in Javascript or C++. The thing is that currently I cannot find a elegent way to identify a channel object that can used both in js and C++, which is used to log it clearly into a log file.
Any idea?
You can easily add your own data to HTTP channels, they always implement nsIPropertyBag2 and nsIWritablePropertyBag2 interfaces. Something along these lines (untested code, merely to illustrate the principle):
static PRInt64 maxChannelID = -1;
...
nsCOMPtr<nsIWritablePropertyBag2> bag = do_QueryInterface(channel);
if (!bag)
...
nsAutoString prop(NS_LITERAL_STRING("myChannelID"));
PRInt64 channelID;
rv = bag->GetPropertyAsInt64(prop, &channelID);
if (NS_FAILED(rv))
{
// First time that we see that channel, assign it an ID
channelID = ++maxChannelID;
rv = bag->SetPropertyAsInt64(prop, channelID)
if (NS_FAILED(rv))
...
}
printf("Channel ID: %i\n", channelID);
You might want to check what happens on HTTP redirect however. I think that channel properties are copied over to the new channel in that case, not sure whether this is desirable for you.

Categories