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.
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)
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.
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
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,
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
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"
Access a broad range of knowledge to help get the most out of your products and services.