Problem of Copy and Paste VBA

Hello

 

I have developed a code in VBA to copy and paste some EPDM documents but for this to work the document must be opened at least once for it to recognize it.

I don't understand why and how to avoid this. If some have an idea, I'm all for it.

 


 

Hello

No code and more details. We won't be able to help you...

1 Like

Hello

Here is the end of my code in question.

....................

Set FileManagement = CreateObject("Scripting.FileSystemObject")
Source = "C:\source link\" & Cells(l, C). Value
Destination = "C:\recipient link\" & Cells(l, C). Value
FileHandlingCopyFile Source, destination

................

The code is included in a loop, and it works, but the problem is that the copy/paste is only done if I have already opened the document. Surely EPDM is blocking if the document has never been opened.....

Hello

I think it comes from the fact that you use the Windows method.

Try using this EPDM method: http://help.solidworks.com/2015/english/api/epdmapi/EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmFolder8~CopyFile2.html

I only have distant memories of EPM, and it's only a reflection without being the answer... But you shouldn't "unlock" the room before you can do anything? So, maybe it could come from a stupid question of rights to activate?

2 Likes

Extract the @coin37coin file. :)

Edit: as long as we have the rights to these files!

2 Likes

Yes, that's the thing Benoit.LF ... I had warned that these were distant memories;)

Hi all

Quite Coin37coin, you have to extract the file. The code to extract is available in the EPDM API files according to an Axemble formatter

2 Likes

Hello

I arrive well after the battle but if it can be useful to others....

The EPDM documents you want to copy do not necessarily have to be opened at least once or extracted but simply repatriated to the local cacheto be taken into account by the copy and paste function.

The following code is C#, I'll let you translate it into VBA:

EdmVault5 vault;
vault = new EdmVault5();

Vault. LoginAuto("nomducoffre", 0);

string full name = @"C:\safe\directory\file.sldprt"; put the file name with all the path
string file = full name. Substring(full name.LastIndexOf("\\") + 1);
string folder = full name. Substring(0, full name. Length - file. Length - 1);
                    
IEdmFolder5 folder;
folder = vault. GetFolderFromPath(folder);
IEdmFile5 file;
file = folder. GetFile(file);
file. GetFileCopy(this. Handle. ToInt32(), "");

All that's left to do is put your copy and paste function.

Kind regards