Extract and Archive via VBA

Hello

 

I am looking to extract or archive files via a macro of an excel file.

I have a macro that creates documents in PDM from a template in order to have a correct data map.

I saw on different forums that there was an EPDM API that allows you to do a lot of things, however I didn't find the syntax to do this famous lock/unlock...

If anyone has an example, I'm all for it.

Hello

The general documentation is here:

http://help.solidworks.com/2014/English/api/SWHelp_List.html

For your problem, see this:

   If True = file. IsLocked Then

        file. UnlockFile 0, ""

    End If

Or  :

https://forum.solidworks.com/thread/69282

https://forum.solidworks.com/thread/68948

https://forum.solidworks.com/thread/55032

https://forum.solidworks.com/thread/100459

Hello

I've already done this macro
I'm posting a module with the functions I created

I hope it can help you

If you can't get out of it, you have the help of the epdm API which is located in ...\Programs\SOLIDWORKS PDM\API_GB.chm

Don't hesitate if you want a hand to make it work;)


epdm.bas

Thank you both. 

I managed to archive (which interests me the most) and extract with the links given.

On the other hand, for the epdm.bas file you provide, I have a problem with the function, excel does not recognize IEdmFolder9, it gives me an error on the subject. (Undefined standard error).

 

To use the function, I made a 

Lock_File("Full file path") 

Is this the right thing to do?

1 Like

did you add the reference to EPDM in excel?
If so, try to retype the command to see which version it offers you, maybe we don't have the same versions
otherwise you can remove the declaration it will also work I think
 

If I remember correctly how it works, you have to find the ID of your file in EPDM with the full path and then you can archive it
because the path is not its location in EPDM, it's virtual the path in EPDM (I don't know if you follow me ;) )

I'm on EXCEL 2013, now the function crashes to direct() = Split(Link, "\")

I think there is a problem with the references used

In terms of references, I have one missing, it's called: VBAProject

The direct line ()=split (link,"\") is used to retrieve in an array the path of your file separately

Example:

link = "C:\thing\thing\file.atnotwhat

direct(0) = "C:"
direct(1)="foo"
direct(2)="bidule"
direct(3)="file.atnotwhat"

then I recompose it without the file name
which gives me after the execution of the loop that I
 

Lockfolder = "C:\foo\doodle\"


Are you sure of the name of the missing reference vbaproject because even I don't use it
Besides, I've never seen her

you can maybe do a different function than mine to recover the file path
Now you have the idea;)
 

I'm on Excel 2010

1 Like

if you can make a screenshot of your references otherwise it may help me
In Visual Basic, Tools, References

1 Like

I solved the problem by setting the direct() array with a dim direct() as string, and I don't have a problem anymore.

1 Like

Cool glad I was able to help you;)

1 Like