To open files from the project workspace folder

To open files from the project workspace folder

RoyWickrama_RWEI
Advisor Advisor
1,105 Views
2 Replies
Message 1 of 3

To open files from the project workspace folder

RoyWickrama_RWEI
Advisor
Advisor

Need to open files from the project workspace.

But, not doing well. Request help. Thanks.

 

2019-04-13 18_0425.png

 

 

Imports System.Windows.Forms
Imports System.IO
Sub main()
Dim oInventorApplication As Inventor.Application
oInventorApplication = ThisApplication

Dim FSO As Object 'File system object
Dim oFolder_WS As Object 'File object
Dim oSubFolder_WS As Object 'Sub folder object
Dim oFile_Folder_WS As Object 'Object
Dim oDoc As Document
Dim oPath As Object 'String
Dim oWS_w_Slash As Object 'String
oPath = ThisDoc.Path
'Clipboard.SetText(oPath)
'xx = Clipboard.GetText

oWS_wo_Slash = ThisApplication.FileLocations.Workspace
oWS_w_Slash = oWS_wo_Slash & "\"
MessageBox.Show("WorkSpace: " & oWS_w_Slash, "iLogic")

FSO = CreateObject("Scripting.FileSystemObject")
' oWS_wo_Slash = "D:\Vault Workspace\Libraries_Admin_Materials"
oFolder_WS = FSO.GetFolder(oWS_wo_Slash)

For Each oFile_Folder_WS In oFolder_WS.Files
If Right(oFile_Folder_WS.Name, 3) = "ipt" Or Right(oFile_Folder_WS.Name, 3) = "iam" Then
MessageBox.Show("oSubFolder_WS: " & oFolder_WS.Name _
& vbLf & "oFile_Folder_WS: " & oFile_Folder_WS.Name, "Title")
'open the file invisibly
oDoc_to_Open = ThisApplication.Documents.Open(oFile_Folder_WS, False)

End If
Next oFile_Folder_WS

For Each oSubFolder_WS In oFolder_WS.SubFolders
If oSubFolder_WS.name.contains("_V") Then
'Do nothing
Else
MessageBox.Show("oSubFolder_WS: " & oSubFolder_WS.name, "Title")
For Each oFile_Folder_WS In oSubFolder_WS.Files

Next oFile_Folder_WS

End If
Next
End Sub

 

 

0 Likes
Accepted solutions (1)
1,106 Views
2 Replies
Replies (2)
Message 2 of 3

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, I am not very clear about what you are trying to do, but if you specify the route correctly, you will access the file that you want to open, I suppose you should try some lines like these

 

Sub Main() 
Dim oInventorApplication As Inventor.Application
oInventorApplication = ThisApplication

Dim FSO As Object 'File system object
Dim oFolder_WS As Object 'File object
Dim oSubFolder_WS As Object 'Sub folder object
Dim oFile_Folder_WS As Object 'Object
Dim oDoc As Document
Dim oPath As Object 'String
Dim oWS_w_Slash As Object 'String
oPath = ThisDoc.Path
'Clipboard.SetText(oPath)
'xx = Clipboard.GetText

oWS_wo_Slash = ThisApplication.FileLocations.Workspace
oWS_w_Slash = oWS_wo_Slash & "\"
MessageBox.Show("WorkSpace: " & oWS_w_Slash, "iLogic")

FSO = CreateObject("Scripting.FileSystemObject")
' oWS_wo_Slash = "D:\Vault Workspace\Libraries_Admin_Materials"
oFolder_WS = FSO.GetFolder(oWS_wo_Slash)

For Each oFile_Folder_WS In oFolder_WS.Files
If Right(oFile_Folder_WS.Name, 3) = "ipt" Or Right(oFile_Folder_WS.Name, 3) = "iam" Then
MessageBox.Show("oSubFolder_WS: " & oFolder_WS.Name _
& vbLf & "oFile_Folder_WS: " & oFile_Folder_WS.Name, "Title")
'open the file invisibly


Dim ofilepath As String =  oWS_w_Slash & oFile_Folder_WS.name
oDoc_to_Open = ThisApplication.Documents.Open(ofilepath, False)



oDoc_to_Open.Close

End If
Next oFile_Folder_WS

For Each oSubFolder_WS In oFolder_WS.SubFolders
If oSubFolder_WS.name.contains("_V") Then
'Do nothing
Else
MessageBox.Show("oSubFolder_WS: " & oSubFolder_WS.name, "Title")
For Each oFile_Folder_WS In oSubFolder_WS.Files

Next oFile_Folder_WS

End If
Next
End Sub

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 3

RoyWickrama_RWEI
Advisor
Advisor

Thanks a lot. I was thinking that 

oFile_Folder_WS

oFile_Folder_WS (as above)  in my rule was the full path. With your reply, Your rely led me to understand the fault.

The rule that I am building up has many uses: thanks a lot.

0 Likes