How do I append folder location to filename?

How do I append folder location to filename?

karthur1
Mentor Mentor
506 Views
3 Replies
Message 1 of 4

How do I append folder location to filename?

karthur1
Mentor
Mentor

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?   

 

Thanks

 

 

 

0 Likes
507 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

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

 

 

0 Likes
Message 3 of 4

Curtis_Waguespack
Consultant
Consultant

Hi karthur1,

 

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

http://inventortrenches.blogspot.com/2011/07/ilogic-to-save-pdf-files-to-new.html

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com


EESignature

0 Likes
Message 4 of 4

Anonymous
Not applicable

 

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"

 

0 Likes