2

So I'm really confused right now. Out of the blue my code gets me the error "DOS Sharing violation".

Image with the Error

It's weird because, it says that is trying to save my document, but I just want to open it.

This is my Code:

Public Sub ReadActivity()
Dim vsoDocument As Visio.Document
Dim vsoPage As Visio.Page


Set vsoDocument = Documents.Open("C:\Users\Philip\Dropbox\Test\Aktivität0.vsdx")
Set vsoPage = vsoDocument.Pages(1)

SvgExport (ActiveDocument.path & "\files_and_images\" & Left(ActiveDocument.name, (InStrRev(ActiveDocument.name, ".", -1, vbTextCompare) - 1)) & ".svg") 
CreateCodeActivity

vsoDocument.Close
End Sub

So as you might see the code is simple nothing special is going on. Before calling the method I'm using this for encoding my textfile: VBA : save a file with UTF-8 without BOM

And two things are very weird. First of all, I used this method two days in a row for coding the method "CreateCodeActivity" and I didn't have any problems. And second, if I call the method let's say three times, on the third time everything works perfectly...

Where might be the problem?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Philipp Mochine
  • 4,351
  • 10
  • 36
  • 68
  • Do you use Kaspersky AntiVir? https://forum.kaspersky.com/index.php?s=2932812927f84277db86e585f190a644&showtopic=360718&pid=2646952&st=0entry2646952 – Shmukko Feb 09 '17 at 12:25
  • No, but good point. Maybe it's the windows defense program... I'll check it out – Philipp Mochine Feb 09 '17 at 12:28

1 Answers1

1

Thank you @Shmukko for the tip, it is really the windows defender that gives me the error.

For Windows 10 the solution is: Go to Settings and select Update & security -> Windows Defender. Select Exclude a file extension and enter the file type for Visio.

That's it.

Philipp Mochine
  • 4,351
  • 10
  • 36
  • 68