Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I append folder location to filename?

3 REPLIES 3
Reply
Message 1 of 4
karthur1
356 Views, 3 Replies

How do I append folder location to filename?

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

 

 

 

3 REPLIES 3
Message 2 of 4
mehatfie
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

 

 

Message 3 of 4

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


Message 4 of 4
mttb
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"

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report