Export Layer color properties and Layer Line propert

Started by diwakaramit, April 12, 2022, 01:12:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

diwakaramit

Hello-
I have a Visio file with multipage . In each page there are layers and layers are a colored line. I am trying to export layer name with page name and also trying to export the layer information (like layer color, layer line property). I found this code that works well to export the layer name to a .TXT file but when i try to export to "XLSX" and open the excel i get an error that says "Excel cannot open the file because the file format or extension is invalid". Can you please point out whats wrong with the code? and also suggest how can i export layer properties to excel.
Thank you

Paul Herber

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

diwakaramit

I am sorry for not pasting the code that i had used. and Also noticed that i did not attached the Visio file, but i am sorry i have to attach the dummy visio file here and not the original one due to rights issues.

Sub List_page_Layers()

Dim Pageobj As Visio.Page
Dim PageLayer As Visio.Layer
Dim myFile As String
Dim layerVal As String
Dim searchString As String
searchString = "Page" 'This allows me to filter as there were a couple of pages I wasn't interested and all other pages had a common string in their name
myFile = "C:\\Temp\\Layers.xlsx"

Open myFile For Output As #1

For Each Pageobj In ActiveDocument.Pages
    If InStr(Pageobj.Name, searchString) Then
        For Each PageLayer In Pageobj.Layers
            layerVal = Pageobj.Name & " - " & PageLayer.Name

            Write #1, layerVal
        Next
    End If

Next
Close #1
End Sub

Paul Herber

That code is writing a text file, just changing the file extension isn't going to change the file format.
You need some proper code to output in Excel format.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

diwakaramit

ok, i will do some research then on how to print in excel format.

Paul Herber

It's more than just printing in Excel format. You'll need to add a VBA module to do XLS/XLSX format output.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

wapperdude

Visio 2019 Pro