Cannot access specified file

[ Edited ]

I've written that opens a given draft and reads summary info from the file.

I have tested it on multiple computer and it works on some computers. On others it returns a messagebox: "Cannot access specified file. D:\Project\test.dft".


Dim se As Object  'SolidEdgeFramework.Application
Dim mDoc As Object 'SolidEdgeFramework.SolidEdgeDocument
Dim DFTToOpen As String = "test"
Dim FileLocation As String = "D:\Project"

se = GetObject(, "SolidEdge.Application")
mDoc = se.ActiveDocument

mDoc = se.Documents.Open(FileLocation & "\" & DFTToOpen & ".dft")


We are running windows 7 (with windows defender and Norman Anti-virus) I have tested it accross multiple machines with ST4 and ST6

Maarten Elings | Mechanical Engineer

Re: Cannot access specified file



some questions:


  1. Your code fragment shown, wouldn't work on any computer. You define a string variable named FileLocatio, but when you want to use the variable, you write FileLocation (could be also just a typo while pasting code into your post).
  2. Why do you assign se.ActiveDocument to mDoc first, if you assign immediately after to mDoc the to be opened document?
  3. Why don't you use strict types for se and mDoc instead of type Object?
  4. Are you sure, the file to be opened does exist and isn't already opened or locked by another process? Maybe by a still running edge.exe process (check the Task Manager).
Kind regards,
Wolfgang Kunert -

Re: Cannot access specified file

In addition to what Wolfgang mentioned, is this VBA code or Visual Basic .NET? If .NET, you should first test the path using System.IO.File.Exists().

Jason Newell
Applications Architect

Re: Cannot access specified file

woops, that that FileLocatio(n) a typo (edited it in the code above);
And you're right it the se.ActiveDocument could/should be removed, it's unnecessary but I doubt it causes this error.
I've used this code from an older example where se is defined as an object instead of SolidEdgeFramework.Application I'll update it.

I'm 100% sure the file is there. On all the computer I tested I created the Project folder on the D: drive and added the same test files.
it works flawless on some but gives the 'Cannot access specified file' message on others.


I'm using (using visual studio 2015)

Maarten Elings | Mechanical Engineer

Re: Cannot access specified file



my assumption still is that the file you want to open is locked by another (crashed) Edge process. Please check before running your program that the file isn't already loaded in the current Solid Edge session you connect to and that there is only 1 Edge process visible in the Task Manager (on tab processes).


Kind regards,
Wolfgang Kunert -