I got this problem at work that I have to do a lot with iManage (aka FileSite, DeskSite, WorkSite etc.) and maybe you've heard of it.
Anyways, what I'm trying to do is to write a VBA code which will be able to download a particular file based on its InFin number (7-digit number that is assigned to every file when being uploaded to iManage) and then place the file somewhere; For example, on the Desktop.
I know that iManage does expose an object model and I've already set the reference to IManExtLib.dll
I believe that the command I need is the Copy.Cmd (I don't want to cut sth from WorkSite but only download a copy of the file for the performed task).
Any help would be appreciated.
Assuming you already have a DMS session, you need to get an IManDocument object for your document you're trying to get and then call the GetCopy method. As an example, the following retrieves a physical copy of document number 123456 to a temp folder. Note you'll need to add a reference to IManage.dll as opposed to IManExtLib.dll.
Dim dmsRoot As IManDMS
Dim dmsSession As IManSession
Dim dmsDatabase As IManDatabase
Dim doc As IManDocument
Dim tempDocName As String
Const ServerName As String = "YourDMS"
Const DatabaseName As String = "YourDatabaseName"
Const DocNumToFind = 123456
Const DocVerToFind = 1
tempDocName = "C:\temp\mydoc.doc"
Set dmsRoot = New ManDMS
Set dmsSession = dmsRoot.Sessions.Add(ServerName)
dmsSession.TrustedLogin
Set dmsDatabase = dmsSession.Databases.ItemByName(DatabaseName)
Set doc = dmsDatabase.GetDocument(DocNumToFind, DocVerToFind)
doc.GetCopy tempDocName, imGetCopyOptions.imNativeFormat
Related
I am trying to write an program to extract zipped files using vb.net. I am facing a problem - when I try to extract the files, it ask fro replacement agreement, but I need to extract that files without asking for my an agreement.
This is the code I use:
Dim shObj As Object = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"))
Dim outputFolder As String = appPath
Dim inputZip As String = appPath + "\patchFile.zip"
IO.Directory.CreateDirectory(outputFolder)
'Declare the folder where the items will be extracted.
Dim output As Object = shObj.NameSpace((outputFolder))
'Declare the input zip file.
Dim input As Object = shObj.NameSpace((inputZip))
'Extract the items from the zip file.
output.CopyHere((input.Items), 4)
I think you can use the second parameter of CopyHere to respond Yes To All for any dialog box displayed and it should avoid your dialog box.
output.CopyHere((input.Items), 16)
Edit :
And if you still need option 4 to not show progress, you can combine both so it would be 20 instead of 16
Hi i've used the code bellow successfully at the beginning but i don't know what i did so it stopped creating the file MessageIO.dat under the folder (ProgramFiles)\UniWin Activator Data
i used this code: (result: created only folder UniWin Activator Data)
Dim UniWinPath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "UniWin Activator Data")
Directory.CreateDirectory(UniWinPath)
Dim MsgIO = Path.Combine(UniWinPath, "\MessageIO.dat")
File.Create(MsgIO)
and used this: (result: error at the command File.Create)
Dim UniWinPath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "UniWin Activator Data\MessageIO.dat")
File.Create(UniWinPath)
and used this: (result: nothing happened)
Dim UniWinPath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "UniWin Activator Data")
Dim MsgIO = Path.Combine(UniWinPath, "\MessageIO.dat")
File.Create(MsgIO)
what's the way to create that file? (I have admin rights already)
The first of your code is perfectly fine. Just change Dim MsgIO = Path.Combine(UniWinPath, "\MessageIO.dat") to Dim MsgIO = Path.Combine(UniWinPath, "MessageIO.dat"). (Remove the backslash). Path.Combine automatically adds one. And as always, to access special directories, make sure you have Administrator Privilleges. The reason the last two codes aren't working is that File.Create creates a file in an existing directory. It can't create the directory itself.
When combining paths, you should not specify the "\" char at begining of the second path item as this will mean the root path!
for example, Path.Combine("D:\Folder1", "\MessageIO.dat") will result "\MessageIO.dat". but you have to write Path.Combine("D:\Folder1", "MessageIO.dat") which will return "D:\Folder1\MessageIO.dat"
Note: in windows 7 or above, access to special folders like as Program Files require special permissions! check that your app has such permission. (you can test for other norman folder first to ensure other parts of your code is ok)
Due to a company policy on how the PDM system operates, when the user checks in a file, the local copy is deleted from the users cache. My macro checks files out, edits them and checks back in again. If I try and edit a file that has just been edited I get a 'file not found' error (because it's been deleted from cache). I have tried to get around this by writing a sub to get the latest copy of a file immediatly before editing it to ensure there is always a file present but the code doesnt seem to retrieve the file. The sub is as below.
Sub GetLatest(fName As String)
Dim vaultName As String
Dim eVault As IEdmVault13
Dim eFile As IEdmFile8
Dim BG As IEdmBatchGet
Dim files(1) As EdmSelItem
'log into the vault
vaultName = Config.ReadXMLElement(pathConfig, "vaultname")
Set eVault = New EdmVault5
If Not eVault.IsLoggedIn Then
Call eVault.LoginAuto(vaultName, 0)
End If
'get the file to get lastest
Set eFile = eVault.GetFileFromPath(fName)
'put the file in an array
files(0).mlDocID = 0
files(0).mlProjID = eFile.ID
Set BG = eVault.CreateUtility(EdmUtil_BatchGet)
Call BG.AddSelection(eVault, files())
Call BG.CreateTree(0, EdmGetCmdFlags.Egcf_SkipExisting)
Call BG.GetFiles(0, Nothing)
End Sub
If I manually 'get latest' in the EPDM browser before editing the file, the macro reads it fine. The code is slightly modified from that posted by Michael Dekoning at https://forum.solidworks.com/thread/51105
From first glance, it looks like you are populating the EdmSelItem properties incorrectly.
The docID property is the database ID of the document. The ProjID property is the ID of the containing folder. For getting the latest version, you can use any containing folder, as it will be checked out in all folders. With EPDM, when a file is "shared" it can have multiple parent folder IDs it belongs to, and we can enumerate over then using the methods from iEdmFile5 GetFirstFolderPosition and GetNextFolder.
You can refer to the documentation for further information and examples.
If you want to get a single file, try the following adjustment and see if that does it:
Set eFile = eVault.GetFileFromPath(fName)
Dim eFolder as iEdmFolder5
Dim Pos as iEdmPos5
Set Pos=eFile.GetFirstFolderPosition
Set eFolder=eFile.GetNextFolder(Pos)
'Get the file from the folder
files(0).mlDocID = eFile.ID
files(0).mlProjID = eFolder.ID
When you provide DocID = 0 it tells EPDM to get all the files in the folder specified. Like so:
'Get all files from the folder
files(0).mlDocID = 0
files(0).mlProjID = eFolder.ID
I'm trying to run the following code:
Dim WkOrigin As Workbook
Dim Dataname As String
Dataname = "09.22 Test"
Set WkOrigin = Workbooks.Open(Dataname)
I've tried removing the period from the name, and the code runs fine. Does anyone know how to get around issues with periods in workbook names?
I think you just need to add the extension (.xls or .xlsx) on the end and it should be fine.
Dataname = "09.22 Test.xls"
You may be best fully qualifying it too:
Dataname = "C:\09.22 Test.xls"
Or if on a network use the UNC rather than the mapped drive, this way it will work on other's computers without the mapped drive or if it is mapped to a different letter (so long as they have access rights, obviously):
Dataname = "\\ServerName\SharedName\09.22 Test.xls"
I have been searching the web looking for a way to open a WORD file from a secure network folder by impersonating a user who has access. The closest I've come to finding the answer was this from 2 years ago:
Impersonating in .net (C#) & opening a file via Process.start
Here is the code that I am using. When I set the arguments = LocalFile_Test, everything works perfectly because the user is accessing the local c:\ that is has access to. But when I set arguments = RemoteFile_Test, Word opens up a blank document which is the same effect as if I put garbage in the arguments. So it appears that it cannot find the file even though when I login with the user/domain/password that I specify in the properties below, I can find that exact file name and it is not empty. Does anything jump out at you right away? I appreciate your time.
Dim LocalFile_Test As String = "C:\New.docx"
Dim RemoteFile_Test As String = "\\Server1\Apps\File\New.docx"
Dim MyStartInfo As New System.Diagnostics.ProcessStartInfo
MyStartInfo.FileName = "C:\Program Files\Microsoft Office\Office12\WINWORD.exe "
MyStartInfo.Arguments = LocalFile_Test
MyStartInfo.LoadUserProfile = True
MyStartInfo.UseShellExecute = False
MyStartInfo.UserName = "specialuser"
MyStartInfo.Domain = "mydomainname"
MyStartInfo.Password = New System.Security.SecureString()
MyStartInfo.Password.AppendChar("p"c)
MyStartInfo.Password.AppendChar("a"c)
MyStartInfo.Password.AppendChar("s"c)
MyStartInfo.Password.AppendChar("s"c)
Process.Start(MyStartInfo)
My understanding is that you are trying to get a password protected file from a server, and when you do process start, it just opens up a blank word doc. I think the error is how you are trying to get the file, I think you have to map the actual physical path of the file on the server, like
System.Web.HttpContext.Current.Server.MapPath("\\Server1\Apps\File\New.docx")
From there, I am fairly certain, you need to create network credentials for the user like
System.Net.NetworkCredential=New NetworkCredential(userName:=, password:=)
Finally, once that is done, you can either write the file, or transmit the file like so...
System.Web.HttpContext.Current.Response.TransmitFile(file name)
System.Web.HttpContext.Current.Response.WriteFile(file name)
Then,once you get the file, you can try to open it with process start.
Hope that helps, let me know if what I said doesn't work.