vba Visio:DOS 共享冲突(错误 1532)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42136424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visio: DOS Sharing violation (Error 1532)
提问by Philipp Mochine
So I'm really confused right now. Out of the blue my code gets me the error "DOS Sharing violation".
所以我现在真的很困惑。出乎意料的是,我的代码让我收到错误“DOS 共享冲突”。
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
所以你可能会看到代码很简单,没有什么特别的。在调用该方法之前,我使用它来编码我的文本文件: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...
有两件事非常奇怪。首先,我连续两天使用这个方法对方法“CreateCodeActivity”进行编码,我没有任何问题。其次,如果我调用该方法,让我们说三次,第三次一切正常......
Where might be the problem?
问题可能出在哪里?
采纳答案by Philipp Mochine
Thank you @Shmukko for the tip, it is really the windows defender that gives me the error.
谢谢@Shmukko 的提示,确实是 Windows Defender 给了我错误。
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.
对于 Windows 10,解决方案是:转到“设置”并选择“更新和安全”->“Windows Defender”。选择排除文件扩展名并输入 Visio 的文件类型。
That's it.
就是这样。