Inventor Customization

Inventor Customization

*Expert Elite*
Posts: 4,304
Registered: ‎04-27-2005
Message 1 of 4 (199 Views)

How do I append folder location to filename?

199 Views, 3 Replies
04-27-2012 05:41 AM

I am using this code snippet to open an idw.  With this code, the idw has to reside at the same file path as the current document. 


Sub OpenIDW()


On Error GoTo Oops


Dim oDoc As Document

 Set oDoc = ThisApplication.ActiveDocument  

Dim sFullFileName As String    

 sFullFileName = oDoc.FullFileName    

Dim sDrawingName As String   

 sDrawingName = Left(sFullFileName, Len(sFullFileName) - 4) & ".idw"        

Dim oDrawDoc As DrawingDocument  

 Set oDrawDoc = ThisApplication.Documents.Open(sDrawingName)  

       Exit Sub  

  Oops:     MsgBox "IDW File could not be found. FileName of IDW must be the same as this file.", vbInformation End Sub



"What if"... my idw is not at the same location, but under a subfolder instead..... like this


Part file c:\designs\Drawings\Jobxxx

Idw file c:\designs\Drawings\Jobxxx\IDW


I am sure that this can be done by editing the line "sDrawingName = Left(sFullFileName, Len(sFullFileName) - 4) & ".idw"  " .  Everything I have tried did not work.


Any suggestions?   






Posts: 163
Registered: ‎02-10-2012
Message 2 of 4 (193 Views)

Re: How do I append folder location to filename?

04-27-2012 10:36 AM in reply to: karthur1

Did you create the folder IDW manually? Inventor might not find it if it doesn't exist


You'll need the Path as well as the File Name to place it there, and ensure your adding the neccessary "\" when creating your path



*Expert Elite*
Posts: 2,987
Registered: ‎03-08-2006
Message 3 of 4 (189 Views)

Re: How do I append folder location to filename?

04-27-2012 10:47 AM in reply to: karthur1

Hi karthur1,


Here's one approach to appending the file path to include a subfolder:


I hope this helps.
Best of luck to you in all of your Inventor pursuits,

  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.

Posts: 20
Registered: ‎12-15-2010
Message 4 of 4 (147 Views)

Re: How do I append folder location to filename?

05-08-2012 12:45 AM in reply to: karthur1


FilePath = Left$(sfullFilename, InStrRev(sfullFilename, "\") - 1)

ipos = InStrRev(sfullFilename, "\")
temp = Right$(sfullFilename, Len(sfullFilename) - ipos)
' Get the base filename by getting everything to
' the left of the last period ".".
BaseFilename = Left$(temp, InStrRev(temp, ".") - 1)


sDrawingName = filepath & "\IDW\" & basefilename & ".idw"


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!