Skip to content

Instantly share code, notes, and snippets.

View nbelyh's full-sized avatar

Nikolay Belykh nbelyh

View GitHub Profile
@nbelyh
nbelyh / gist:8108643
Last active January 1, 2016 06:59
Detecting all pages out-of-the page (sample code illustrating "GetFormulas" in Visio)
using System;
using System.Collections.Generic;
using Microsoft.Office.Interop.Visio;
namespace ConsoleApplication1
{
class Program
{
//
// медленно!
<style>
.tooltip-inner {
background-color: #fff;
color: #000;
border: 1px solid #000;
min-width: 150px;
}
</style>
<style>
.panel-body {
max-height: none;
}
</style>
<style>
.popover {
min-width: 400px;
min-height: 250px;
max-width: none;
}
.popover img {
height: 150px;
width: auto;
float: left;
@nbelyh
nbelyh / list-shapes.svgpublish.js
Last active August 28, 2017 20:26
SvgPublish: list text of all shapes to console.
console.log("listing shapes")
// for each diagram shape, log it's name
$.each(diagram.shapes, function(id) {
var shape = diagram.shapes[id];
console.log(shape.Text);
})
@nbelyh
nbelyh / show-toolbars.visio-online.js
Last active August 28, 2017 19:06
VisioOnline: Hello world. Simple script that shows the toolbar. To make sure it works :)
Visio.run(function(ctx) {
ctx.document.application.showToolbars = true;
return ctx.sync();
});
@nbelyh
nbelyh / vispub-selection-changed.js
Last active August 28, 2017 20:26
SvgPublish: show message on selection change.
// show message box on shape selection
diagram.selectionChanged.add(function(shapeId) {
// if selected
if (shapeId) {
var shape = diagram.shapes[shapeId];
alert('you selected shape: ' + shapeId + ', text:' + shape.Text);
}
})
@nbelyh
nbelyh / print_all_shapes_text.js
Last active August 28, 2017 19:07
VisioOnline: Printing all shapes text in active page. The following example shows you how to print shape text value from an array shape objects
Visio.run(function (ctx) {
var page = ctx.document.getActivePage();
var shapes = page.shapes;
shapes.load();
return ctx.sync().then(function () {
for (var i = 0; i < shapes.items.length; i++) {
var shape = shapes.items[i];
console.log("Shape Text: " + shape.text);
}
});
@nbelyh
nbelyh / application.js
Last active August 28, 2017 19:35
VisioOnline: Application object example. https://dev.office.com/reference/add-ins/visio/application.
Visio.run(function (ctx) {
var application = ctx.document.application;
application.showToolbars = false;
return ctx.sync();
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
@nbelyh
nbelyh / comment.js
Last active August 28, 2017 19:35
VisioOnline: Comment Object example. https://dev.office.com/reference/add-ins/visio/comment.
Visio.run(function (ctx) {
var activePage = ctx.document.getActivePage();
var shapeName = "Position Belt.41";
var shape = activePage.shapes.getItem(shapeName);
var shapecomments= shape.comments;
shapecomments.load();
return ctx.sync().then(function () {
for(var i=0; i<shapecomments.items.length;i++)
{
var comment= shapecomments.items[i];