<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Search file path for file in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/search-file-path-for-file/m-p/10261742#M123618</link>
    <description>&lt;P&gt;I think this should find your file:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main
	Dim MyDrawDoc As DrawingDocument = ThisDoc.Document
	Dim mySavePath As String = GetPath(MyDrawDoc, "\Title Block Information.xlsx")
	MessageBox.Show(mySavePath, "Result")
End Sub

Private Function GetPath(aDoc As Document, searchName As String) As String
	Dim Result As String = "Excel File not found"
	Dim sFullDocumentPath As String = aDoc.FullFileName
	Dim SearchFolder As String = Left(sFullDocumentPath, sFullDocumentPath.LastIndexOf("\"))
CheckFolder :	
	Logger.Trace(SearchFolder)
	If System.IO.File.Exists(SearchFolder &amp;amp; searchName)
		Result = SearchFolder &amp;amp; searchName
		Return Result
	Else If SearchFolder.Count(Function(c As Char) c = "\")&amp;gt;0
		SearchFolder = Left(SearchFolder, SearchFolder.LastIndexOf("\"))
		GoTo CheckFolder
	End If
	Return Result
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if you have any questions, or if this is not working as intended&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Apr 2021 03:48:57 GMT</pubDate>
    <dc:creator>J-Camper</dc:creator>
    <dc:date>2021-04-23T03:48:57Z</dc:date>
    <item>
      <title>Search file path for file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/search-file-path-for-file/m-p/10261027#M123608</link>
      <description>&lt;P&gt;We will have a large project folder structure. I would like to run an ilogic rule that searches for an excel document named "Title Block Information.xlsx". The rule should START searching where the drawing is saved, if file is found return the path, else back up one level and search again, ect. There may be multiple excel sheets in the folder structure but the rule should always find the one saved closest to the drawing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below you will find what I had when I gave up. The issues:&lt;/P&gt;&lt;P&gt;It searches starting at the top of the file structure and searches down to the drawing. I need it to go the other way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main
	Dim MyDrawDoc As DrawingDocument=ThisDoc.Document
	Dim mySavePath As String = GetPath(MyDrawDoc)
End Sub

Private Function GetPath(oDrawDoc As DrawingDocument) As String
Try
	Dim sFullDocumentPath As String = IO.Path.GetDirectoryName(oDrawDoc.FullDocumentName)
	Dim aPathParts() As String = Strings.Split(sFullDocumentPath, "\")
	
	For i=0 To UBound(aPathParts)
		sExcelPathx = sExcelPathx &amp;amp; aPathparts(i) &amp;amp; "\"
msgbox(sExcelPathx)
		If System.IO.File.Exists(sExcelPathx &amp;amp; "\Title Block Information.xlsx") Then
			sExcelPathx = sExcelPathx &amp;amp; "Title Block Information.xlsx\"
			bFound = True
		End If
	Next
	
	'only return path if folder $Fabrication Data was found
	If bfound = True Then
		partofpath = Left(sExcelPathx, sExcelPathx.IndexOf(".xlsx"))
		Dim sExcelPath As String = partofpath &amp;amp; ".xlsx"
		'MsgBox(sExcelPath)
		Return sExcelPath
	Else
		Return Nothing
End Try

End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 20:53:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/search-file-path-for-file/m-p/10261027#M123608</guid>
      <dc:creator>To_Efficiency_and_Beyond</dc:creator>
      <dc:date>2021-04-22T20:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Search file path for file</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/search-file-path-for-file/m-p/10261742#M123618</link>
      <description>&lt;P&gt;I think this should find your file:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main
	Dim MyDrawDoc As DrawingDocument = ThisDoc.Document
	Dim mySavePath As String = GetPath(MyDrawDoc, "\Title Block Information.xlsx")
	MessageBox.Show(mySavePath, "Result")
End Sub

Private Function GetPath(aDoc As Document, searchName As String) As String
	Dim Result As String = "Excel File not found"
	Dim sFullDocumentPath As String = aDoc.FullFileName
	Dim SearchFolder As String = Left(sFullDocumentPath, sFullDocumentPath.LastIndexOf("\"))
CheckFolder :	
	Logger.Trace(SearchFolder)
	If System.IO.File.Exists(SearchFolder &amp;amp; searchName)
		Result = SearchFolder &amp;amp; searchName
		Return Result
	Else If SearchFolder.Count(Function(c As Char) c = "\")&amp;gt;0
		SearchFolder = Left(SearchFolder, SearchFolder.LastIndexOf("\"))
		GoTo CheckFolder
	End If
	Return Result
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if you have any questions, or if this is not working as intended&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 03:48:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/search-file-path-for-file/m-p/10261742#M123618</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2021-04-23T03:48:57Z</dc:date>
    </item>
  </channel>
</rss>

