Hi everyone
I built a macro for Visio 2013 and in a few months, I will have to use visio online.So I'd like to update my macro.
So my question is simple: is there a way to build a macro or an addin with vsto on visio online? (or any other way)
I make some searches and I find nothing and I don't have yet any access to visio online
What Visio Online plan you mean ?
If you get Plan 2 you can use your macro again !
are you sure?
Not with visio 2016 but only with visio online, I could edit macro?
Because I found an article wich said that this feature wasn't exist with visio online
Well, unfortunately as of now you can't run VBA in the browser. VBA is developed for desktops;
so to run it in a browser, one would need a complete emulation layer over forms and desktop objects (like files).
Well, this layer does not exist.
You can run javascript in the browser though;
you might want to check for Visio Online API (https://dev.office.com/blogs/visio-javascript-apis-preview) (but that won't work on the desktop).
Microsoft is yet to provide "Apps for Visio". Unfortunately I don't know when and if it's going to happen.
I think you can refer to "Apps for Office (https://technet.microsoft.com/en-us/library/jj219429.aspx)" as an example of what you could expect in 1-5 year timespan.
Unfortunately Microsoft Store does not accept apps for Visio as well yet (as they do not exist)
Maybe with coming of WebAssembly someone will create something capable of running VBA in the browser;
that person will be a hero. But most probably nobody will, and you'd better focus on javascript
Ok thanks
I subscribe for a visio online trial and I think that I can't do what I'm doing with my visio 2016 on visio online
First, I use data shape like cost and in my accro I have some lines like:
Shape1ConnectorId = Shape1.ConnectedShapes _
(visConnectedShapesIncomingNodes, "")
According to this link: https://blogs.msdn.microsoft.com/visio/2017/09/25/migrate-from-visio-web-access-to-visio-online/ , Javascript couldn't execute neither this kind of command nor set shape values
Am I right?
python, c++, or R?
what about using a container or viewer to pull down drawing into some light weight visio and do it there then post back up
(still has the benefit of sharing across users and such...aka visio SKU of a sharepoint).
The idea is to not install visio anymore, only with visio online, we would like to be able to make the calculation we need
I have already written my macro in c#
Can you show the macro, so that we could suggest something reasonable?
Yes of course:
The first macro help me to calculate the value inside my shape on the left depending on the values of the shapes which are connected to it by an incomming connection
Public Sub FindOffPageShapes()
Dim shp As Visio.Shape
Dim pagShape As Visio.Shape
Dim Shape1 As Visio.Shape
Dim lngShapeIDs() As Long
Dim Shape2 As Visio.Shape
Dim ConnectorsIds() As Long
Dim Shape1ConnectorId() As Long
Dim Connector As Visio.Shape
Dim Tempo As Visio.Shape
Dim lngShapeID As Long
Dim i As Integer
Dim j As Integer
Dim K As Integer
Dim Value As Double
Dim value2 As Double
Dim Value3 As Double
Set pagShape = Visio.ActivePage.PageSheet
For l = 1 To 10
For Each shp In Visio.ActivePage.Shapes
Set Shape1 = shp
If Shape1.OneD = 0 Then
Debug.Print (Shape1.Name)
lngShapeIDs = Shape1.ConnectedShapes _
(visConnectedShapesIncomingNodes, "")
For i = 0 To UBound(lngShapeIDs)
Set Shape2 = ActivePage.Shapes.ItemFromID(lngShapeIDs(i))
Shape1ConnectorId = Shape1.ConnectedShapes _
(visConnectedShapesIncomingNodes, "")
If UBound(Shape1ConnectorId) > 0 Then
Value3 = 0
For j = 0 To UBound(Shape1ConnectorId)
Set Connector = ActivePage.Shapes.ItemFromID(Shape1ConnectorId(j))
Debug.Print CStr(Connector.Text)
ConnectorsIds = Connector.GluedShapes(visGluedShapesOutgoing1D, "", Shape1)
For K = 0 To UBound(ConnectorsIds)
Set Tempo = ActivePage.Shapes.ItemFromID(ConnectorsIds(K))
value2 = CDbl(Tempo.Text) * CDbl(Connector.Data1)
Next
Value3 = Value3 + value2
Next
Debug.Print CStr(Value3)
Shape1.Data1 = CStr(Value3)
Shape1.CellsU("prop.Cost").FormulaU = Chr(34) & CStr(Value3) & Chr(34)
Else
Value = 0
ConnectorsIds = Shape1.GluedShapes(visGluedShapesIncoming1D, "", Shape2)
For j = 0 To UBound(ConnectorsIds)
Set Connector = ActivePage.Shapes.ItemFromID(ConnectorsIds(j))
Value = CDbl(Shape2.Data1) * CDbl(Connector.Text)
Debug.Print (Shape1.Name)
Debug.Print (Connector.Name)
Next
Shape1.Data1 = CStr(Value)
Shape1.CellsU("prop.Cost").FormulaU = Chr(34) & CStr(Value) & Chr(34)
End If
Next
End If
Next shp
Next l
Visio.Application.Addons("VisRpt").Run ("/rptDefName=ProjectSorting /rptOutput=EXCEL")
The next macro generated a report in a new sheet to get all the connector with input and output shapes
Sub ExcelReport(ByVal pgCnt, shpCnt, ByRef cnxArry() As Variant)
Dim i As Integer, j As Integer
Dim p As Integer
Dim m As Integer
Dim XlApp As Object
Dim XlWrkbook As Excel.Workbook
Dim XlSheet As Excel.Worksheet
Dim prpData(10, 10) As String
Set XlApp = CreateObject("Excel.Application")
Set XlWrkbook = XlApp.Workbooks.Add
Set XlSheet = XlWrkbook.Worksheets("Sheet1")
XlApp.Visible = False
XlApp.ScreenUpdating = False
XlSheet.Cells(1, 1) = "PAGE"
XlSheet.Cells(1, 2) = "CONNECTOR"
XlSheet.Cells(1, 3) = "FROM SHAPE"
XlSheet.Cells(1, 4) = "TO SHAPE"
For p = 1 To pgCnt
m = 0
j = 0
If p = 1 Then
XlWrkbook.Worksheets("Sheet" & p).Activate
ElseIf p >= 2 Then
XlWrkbook.Worksheets("Sheet" & p).Activate
Set XlSheet = XlWrkbook.Worksheets("Sheet" & p)
XlSheet.Cells(1, 1) = "PAGE"
XlSheet.Cells(1, 2) = "CONNECTOR"
XlSheet.Cells(1, 3) = "FROM SHAPE"
XlSheet.Cells(1, 4) = "TO SHAPE"
End If
For i = 1 To shpCnt
conShp = cnxArry(0, 0, 0, 0, 0, 0, 0, 0, p, i)
If conShp = Empty Then
m = m + 1
GoTo Skippy
End If
XlSheet.Cells(i + 1 + j - m, 1) = cnxArry(0, 0, 0, 0, 0, 0, 0, 0, p, 0)
XlSheet.Cells(i + 1 + j - m, 2) = cnxArry(0, 0, 0, 0, 0, 0, 0, 0, p, i)
XlSheet.Cells(i + 1 + j - m, 3) = cnxArry(0, 0, 0, 0, 0, 0, 0, 1, p, i)
XlSheet.Cells(i + 1 + j - m, 4) = cnxArry(0, 0, 0, 0, 0, 1, 1, 1, p, i)
XlSheet.Cells(i + 1 + j - m, 5) = cnxArry(0, 0, 0, 1, 1, 1, 1, 1, p, i)
Skippy:
Next i
NxtPg:
Next p
Dim LastCol As Long
Dim LastRow As Long
Dim q As Long
Dim rowCell As Range
Dim FirstRow As Range
Dim myUsedRng As Range
Dim xptSheet As Excel.Worksheet
p = 0
For Each xptSheet In XlWrkbook.Sheets
p = p + 1
xptSheet.Activate
Set myUsedRng = xptSheet.UsedRange
Set FirstRow = myUsedRng.Rows(1).Cells
LastCol = myUsedRng.Columns.Count
LastRow = myUsedRng.Rows.Count
With myUsedRng
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
'Add light borders around all individual used cells
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlInsideVertical).Weight = xlThin
.Borders(xlInsideHorizontal).Weight = xlThin
'Heavy outer border around the used worksheet region
.Borders(xlEdgeLeft).Weight = xlMedium
.Borders(xlEdgeTop).Weight = xlMedium
.Borders(xlEdgeBottom).Weight = xlMedium
.Borders(xlEdgeRight).Weight = xlMedium
'Set used cell background fill to white
.Interior.Color = RGB(255, 255, 255)
End With
' Double line: selection range used is top row of cells
FirstRow.Borders(xlEdgeBottom).LineStyle = xlDouble
FirstRow.Borders(xlEdgeBottom).Weight = xlThick
'Set top row upper case, font bold, cell background fill to light yellow, and set column widths
For Each rowCell In FirstRow
rowCell = UCase(rowCell)
rowCell.Font.Bold = True
rowCell.Font.Color = RGB(0, 0, 200)
rowCell.Font.Size = 9
rowCell.Interior.Color = RGB(255, 255, 204)
rowCell.EntireColumn.AutoFit
Next rowCell
If p <= pgCnt Then
Call VisPushBack(myUsedRng, xptSheet.Name)
End If
Next xptSheet
XlApp.ScreenUpdating = True
XlApp.Visible = True
XlWrkbook.Close SaveChanges:=False
End Sub
So any idea if I could say bye to Visio 2016?
The macro itself is not a problem, can be done in javascript;
however, "shape reporting" Visio built-in add-on and Excel you are using is a problem.
Both are not available out-of-the box in the browser. Would you consider replacing them with some javascript code?
(I guess that would be quite a lot of code actually)
The options (replacement) for excel/reports:
- SharePoint Excel Services (sheets)
- Google Sheets
- Javascript Excel parser (such as sheet.js (https://sheetjs.com/))
I would estimate 1 week to re-write in javascript
But I use some function which doesn't exist in javascript no?
I never use javascript so I don't know how powerfull is this tool
Yes, you use Visio "shape report" function and Excel application.
Quote from: Nikolay on April 25, 2018, 11:29:30 AM
1. Visio.Application.Addons("VisRpt").Run ("/rptDefName=ProjectSorting /rptOutput=EXCEL")
2. Set XlApp = CreateObject("Excel.Application")
These two lines are not possible in the browser. I.e. it is not actually about javascript, it is about the browser.
For (1), user must have Visio installed, for (2), user must have Excel installed.
Now imagine Android smartphone that runs the browser.
Yes but for example, this kind of function :
ConnectorsIds = Connector.GluedShapes(visGluedShapesOutgoing1D, "", Shape1)
I can use it with javascript?
The names of the functions are different.
But many of them exists in the Visio online API as well.
Not sure about ConnectedShapes though.
Here is the reference:
https://dev.office.com/reference/add-ins/visio/visio-javascript-reference-overview?product=visio
You could check out my alternative svg export. It has connectedShapes, but documentation still kind of sucks :-[
https://nbelyh.github.io/svgpublishdemo/AdvWorksOLTPSchemaVisio.html
Code for that thing (on shape click):
var shape = diagram.shapes[id];
if (shape.ConnectedTo) {
shape.ConnectedTo.forEach( function(item) {
d3.select("#" + item).selectAll("g").style("fill", "#Aff");
});
}
if (shape.ConnectedFrom) {
shape.ConnectedFrom.forEach( function(item) {
d3.select("#" + item).selectAll("g").style("fill", "#fAf");
});
}
Ok thank you
I'm gonna to check that this evenning
Hi Everyone
I made some trials and currently, I wouldn't be able to develop it in javascript. Many functions are missing, you don't know where I could find a list of all existing functions for visio Online? Maybe with that, I would be able to do something
Thanks for your feedback
Okay so I tried to do my first javascript application but I'd like to know if there is a way to read the value in my data and to make some calulcation
So for example, I have a shape in which some shapes are getting in, so what I'd like to do is to read the value of my 1D shape and multiply it by a data that I give to my shape for example cost
Any idea of how could I do that?
I don't find a lot of doc for visio online but your table with color help me to achieve some steps
Once again, thank for your time and your help