<?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: VBA Saving: Change default file path and automatically click yes in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7406955#M75229</link>
    <description>&lt;P&gt;Can you post the relevant code so I can take a look at it?&lt;/P&gt;</description>
    <pubDate>Mon, 25 Sep 2017 16:14:56 GMT</pubDate>
    <dc:creator>perrysc</dc:creator>
    <dc:date>2017-09-25T16:14:56Z</dc:date>
    <item>
      <title>VBA Saving: Change default file path and automatically click yes</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7374336#M74902</link>
      <description>&lt;P&gt;I have a program that writes out a list of parts that I need from an autocad drawing and I have a part template that goes and picks up the information from there and either&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;1) &amp;nbsp;Opens the part template and activates that document&lt;/P&gt;&lt;P&gt;2) checks that the parts already exist and input them into the head assembly&lt;BR /&gt;3) if not it saves the part to a specified file location with an unspecified name&lt;/P&gt;&lt;P&gt;4) then it updates the information and inputs the part into the assembly&lt;/P&gt;&lt;P&gt;5) reactivates the assembly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My issue is that I cannot use the file dialog. We use a program that on initial save or save as generates a sequential file number. If I use the file dialog it doesn't trigger the program that generates the part name. So I need to figure out how to target location and automatically say yes so that we aren't rerouting it to the target location every single time and just clicking ok over and over again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated, thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2017 18:30:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7374336#M74902</guid>
      <dc:creator>Thomas.Long</dc:creator>
      <dc:date>2017-09-12T18:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Saving: Change default file path and automatically click yes</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7406955#M75229</link>
      <description>&lt;P&gt;Can you post the relevant code so I can take a look at it?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 16:14:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7406955#M75229</guid>
      <dc:creator>perrysc</dc:creator>
      <dc:date>2017-09-25T16:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Saving: Change default file path and automatically click yes</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7409738#M75270</link>
      <description>&lt;P&gt;Sure, here's my file control functions. Right now, instead of getting the name of the new file, I have to declare the new location and have it look for the latest file. If it doesn't go to the proper location, it won't open the right file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something to note is that while it says to "Create from template", these aren't your typical empty file templates with just properties preset and everything. These are actually fully modeled assemblies with rules associated with them that dynamically model the assemblies based on input information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Private Sub CreateCoverPlates_Click()

    On Error GoTo ErrorHandler

    'Save workbook so that assemblies are getting latest updated file
    ThisWorkbook.Save

    'Declare Variables
    Dim Exist As Boolean
    Dim Rotation As Boolean
    
    Dim CoverPlateGap As Double
    Dim Length As Double
    Dim Width As Double
    Dim Point(2) As Double
    
    Dim i As Integer
    Dim oRow As Integer
    Dim oRow2 As Integer
    
    Dim FileName As String
    Dim JobBook As String
    Dim Location As String
    Dim Material As String
    Dim SheetName As String
    Dim PlateFile As String
    Dim PlateType As String
    Dim Template As String
    
    Dim UOM As UnitsOfMeasure
    
    Dim ListSheet As Worksheet
    Dim JobSheet As Worksheet
    
    Dim Doc As Inventor.Document
    Dim InventorObjects As Variant
    Dim oInventor As Inventor.Application
    
    Dim CoverPlateDoc As PartDocument
    Dim CoverPlateObjects As Variant
    Dim CoverPlateInventor As Inventor.Application
    
    'Setting up file information
    FileName = "INVENTOR COVER PLATES.xlsx"
    JobBook = ThisWorkbook.Name
    Location = "N:\Mechpart\TLONG\Parts Lists\"
    SheetName = "Sheet1"
    Template = "C:\Work\Designs\Project Documents\EDH\Working Projects\Dynamic Base Assemblies\Dynamic Cover Plate.ipt"
    
    'Opening list of created plates
    Workbooks.Open FileName:=Location &amp;amp; FileName, ReadOnly:=True
    'Windows(FileName).Visible = False
    
    'Open new assembly file for cover plate layout
    InventorObjects = FileControl.OpenInventorFile("Assembly (Imperial).iam", True)
    Set oInventor = InventorObjects(0)
    Set Doc = InventorObjects(1)
    
    oInventor.ScreenUpdating = False
    
    Set ListSheet = Workbooks(FileName).Sheets(SheetName)
    Set JobSheet = Workbooks(JobBook).Worksheets("Cover Plates")
    
    oRow = 1
    'Iterate through all cover plates in the list
    With JobSheet
        Do While .Range("A" &amp;amp; oRow) &amp;lt;&amp;gt; ""
        
            Exist = False
            PlateFile = ""
        
            'Determine Plate information
            PlateType = .Range("A" &amp;amp; oRow)
        
            If PlateType = "Surface" Then
                CoverPlateGap = 0.75
                Material = Workbooks(JobBook).Worksheets("PCR").Range("B4")
                
            ElseIf PlateType = "Flush" Then
                CoverPlateGap = 0.9375
                If Workbooks(JobBook).Worksheets("PCR").Range("B5") = True Then
                    If Split(Workbooks(JobBook).Worksheets("PCR").Range("B4"), " ")(1) = "AL" Then
                        Material = "1/8 " &amp;amp; Split(Workbooks(JobBook).Worksheets("PCR").Range("B4"), " ")(1)
                    Else
                        Material = "12GA " &amp;amp; Split(Workbooks(JobBook).Worksheets("PCR").Range("B4"), " ")(1)
                    End If
                Else
                    Material = Workbooks(JobBook).Worksheets("PCR").Range("B4")
                End If
            End If
            
            Length = Application.WorksheetFunction.Max(.Range("B" &amp;amp; oRow), .Range("C" &amp;amp; oRow)) + 2 * CoverPlateGap
            Width = Application.WorksheetFunction.Min(.Range("B" &amp;amp; oRow), .Range("C" &amp;amp; oRow)) + 2 * CoverPlateGap
            
            Point(0) = .Range("D" &amp;amp; oRow) - CoverPlateGap
            Point(1) = .Range("F" &amp;amp; oRow) - CoverPlateGap
            Point(2) = 0
            
            If Abs(.Range("E" &amp;amp; oRow) - .Range("D" &amp;amp; oRow)) &amp;lt; Abs(.Range("G" &amp;amp; oRow) - .Range("F" &amp;amp; oRow)) Then
                Rotation = True
            Else
                Rotation = False
            End If
        
            'Search through the list of existing cover plates for a match
            oRow2 = 1
            Do While ListSheet.Range("A" &amp;amp; oRow2) &amp;lt;&amp;gt; ""
                If ListSheet.Range("A" &amp;amp; oRow2) = Length And ListSheet.Range("B" &amp;amp; oRow2) = Width And ListSheet.Range("C" &amp;amp; oRow2) = Material And UCase(ListSheet.Range("D" &amp;amp; oRow2)) = UCase(PlateType) Then
                    PlateFile = ListSheet.Range("E" &amp;amp; oRow2)
                    Exist = True
                    Exit Do
                End If
                oRow2 = oRow2 + 1
            Loop
            
            If Exist = False Then

                Workbooks(JobBook).Activate
                CoverPlateObjects = FileControl.CreateFromTemplate("C:\Work\Designs\Project Documents\EDH\Working Projects\Dynamic Base Assemblies\Dynamic Cover Plate.ipt")
                Set CoverPlateInventor = CoverPlateObjects(0)
                Set CoverPlateDoc = CoverPlateObjects(1)
                PlateFile = CoverPlateDoc.FullFileName
                
                CoverPlateDoc.Activate
                
                'Update part parameters
                Set UOM = CoverPlateDoc.UnitsOfMeasure
                Set oParameters = CoverPlateDoc.ComponentDefinition.Parameters
                Set oLength = oParameters.Item("CutoutLength")
                Set oWidth = oParameters.Item("CutoutWidth")
                Set oMaterial = oParameters.Item("Material")
                Set oType = oParameters.Item("Type")
                
                oLength.Value = Application.WorksheetFunction.Max(.Range("B" &amp;amp; oRow), .Range("C" &amp;amp; oRow)) * 2.54
                oWidth.Value = Application.WorksheetFunction.Min(.Range("B" &amp;amp; oRow), .Range("C" &amp;amp; oRow)) * 2.54
                oMaterial.Value = UCase(Material)
                oType.Value = UCase(PlateType)
                
                
                'Create new part
                Call InventorFunctions.RuniLogic(CoverPlateInventor, "Create Cover Plate", False)
                Call InventorFunctions.RuniLogic(CoverPlateInventor, "Drawing Creation", False)
                
                Doc.Activate
                
                Workbooks(FileName).Close
                Workbooks.Open FileName:=Location &amp;amp; FileName, ReadOnly:=True
                Set ListSheet = Workbooks(FileName).Sheets(SheetName)
            End If
            
            Call InventorFunctions.PlacePart(oInventor, PlateFile)
            Call InventorFunctions.MovePart(oInventor, PlateFile, Point, Rotation)
            
            oRow = oRow + 1
        Loop
    End With

ErrorHandler:
    'Closing list of created plates
    oInventor.ScreenUpdating = True
    Workbooks(FileName).Close
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;'Creates a copy of a file and opens it
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Public Function CreateFromTemplate(TemplateFile As String) As Variant

    Dim oInventor As Inventor.Application
    Dim InventorObjects As Variant
    Dim Doc As Inventor.Document
    Dim NewFile As String
    
    InventorObjects = OpenInventorFile(TemplateFile, False)
    Set oInventor = InventorObjects(0)
    Set Doc = InventorObjects(1)
    
    Doc.Save
    Doc.Close (True)
    NewFile = FileControl.GetLatestFile(Split(TemplateFile, ".")(UBound(Split(TemplateFile, "."))))
    
    CreateFromTemplate = OpenInventorFile(NewFile, False)

End Function
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\&lt;/PRE&gt;&lt;PRE&gt;'Opens an existing file or creates a new one. Returns the file reference
'Pass it the template you wish to use for a new document. Acceptable template files listed below
' Assembly (Imperial).iam, ASTM Angle.ipt, ASTM Channel.ipt, ASTM Miscellaneous Channel.ipt, ASTM Rectangular Tube.ipt, ASTM Wide Flange Beam.ipt, _
' Copper Bar Part (Imperial).ipt, Grating Material Template (Imperial).ipt, Non-Metallic Sheet Outsourced.ipt, Part - Other (Imperial).ipt, _
' Roll Fromed Coil.ipt, Sheet Metal Part (Imperial).ipt, Weldment (Imperial).iam
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Public Function OpenInventorFile(FileName As String, NewFile As Boolean) As Variant

    On Error Resume Next
    
    Dim InventorObjects(1) As Object
    Dim Doc As Inventor.Document
    Dim oInventor As Inventor.Application
    
    Dim Location As String
    Dim TemplateName As String
    
    Dim DocType As DocumentTypeEnum
    
    'Get open instance of inventor or open one if nothing is found
    Set oInventor = GetObject(, "Inventor.Application")
    If Err Then
        Err.Clear
        Set oInventor = CreateObject("Inventor.Application")
        
        Do Until oInventor.Ready = True
            Application.Wait (1)
        Loop
        
        For j = 1 To oInventor.ApplicationAddIns.Count
            oAddin = oInventor.ApplicationAddIns.Item(j)
            oStr = oStr &amp;amp; j &amp;amp; ") " &amp;amp; oAddin.DisplayName &amp;amp; " - " &amp;amp; oAddin.Activated
        Next
    End If
    
    oInventor.Visible = True
    
    'If this is an old file simply open it
    If NewFile = False Then
        Set Doc = oInventor.Documents.Open(FileName)
    
    'If it is a new file then determine the template and document and add a new file
    Else
        Location = "C:\Work\Designs\Templates\2013\Inventor Templates\Imperial\"
        TemplateName = Location &amp;amp; FileName
        
        If FileName = "Assembly (Imperial).iam" Or FileName = "Weldment (Imperial).iam" Then
            DocType = kAssemblyDocumentObject
        Else
            DocType = kPartDocumentObject
        End If
        
        Set Doc = oInventor.Documents.Add(DocType, TemplateName, True)
    End If

    Set InventorObjects(0) = oInventor
    Set InventorObjects(1) = Doc
    OpenInventorFile = InventorObjects

End Function
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;'Returns the latest instance of a file of the specified extension in a string. Asterisk can be used for any file type
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Public Function GetLatestFile(Extension As String) As String

    Dim FileSpec As String
    Dim LatestFile As String
    Dim Location As String
    Dim FileList() As String
    Dim FileName As String
    
    Location = ActiveWorkbook.Path
    FileSpec = Location &amp;amp; "*.*"
    FileName = Dir(FileSpec)

    Do While Len(FileName) &amp;gt; 0
        If Split(FileName, ".")(UBound(Split(FileName, "."))) = Extension Then
            If LatestFile &amp;lt;&amp;gt; "" Then
                If FileDateTime(Location &amp;amp; FileName) &amp;gt; FileDateTime(LatestFile) Then
                    LatestFile = Location &amp;amp; FileName
                End If
            Else
                LatestFile = Location &amp;amp; FileName
            End If
        End If
        FileName = Dir
    Loop
    
    If LatestFile = "" Then
        MsgBox ("No assemblies found")
        Exit Function
    Else
        GetLatestFile = LatestFile
    End If
End Function
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 13:47:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7409738#M75270</guid>
      <dc:creator>Thomas.Long</dc:creator>
      <dc:date>2017-09-26T13:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Saving: Change default file path and automatically click yes</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7411442#M75286</link>
      <description>&lt;P&gt;I don't quite understand what or where you are trying to accomplish the save thing... but a few ideas....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;oDoc.SaveAs("C:\FileNameHere.ext")&lt;/PRE&gt;
&lt;P&gt;or BEFORE SAVE&lt;/P&gt;
&lt;PRE&gt;oDoc.FullFileName = "C:\FileNameHere"&lt;/PRE&gt;
&lt;P&gt;or to avoid dialogs...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;invApp.SilentOperation = True&lt;BR /&gt;'Must also reset with&lt;BR /&gt;'invApp.SilentOperation = False&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Sep 2017 22:59:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7411442#M75286</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2017-09-26T22:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Saving: Change default file path and automatically click yes</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7412984#M75307</link>
      <description>&lt;P&gt;The thing is that I can't avoid the dialogue. I want the dialogue to pop up, the path to be initially declared, and the file to save without user input. I can't use save as because we use a number generator that occurs on save to determine file name so I have no idea ahead of time what the file is actually supposed to be called.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need is for it to open a document, perform a save action to the intended file path, let the save dialogue come up and then simply have the command manager click yes and record the name of the new file that is being opened so that I can then close the file that I was saving from and open the new file.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 11:52:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7412984#M75307</guid>
      <dc:creator>Thomas.Long</dc:creator>
      <dc:date>2017-09-27T11:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Saving: Change default file path and automatically click yes</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7414125#M75323</link>
      <description>&lt;P&gt;So what you're saying is you have an event trigger set for before save that determines the save name of the file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are wanting to do a "Save copy as" kind of thing but give the file a new name, then open it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, unless your trigger is set on close or something weird, the new file should be already open before launching the save command, so there is no need to store the file name...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 17:38:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7414125#M75323</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2017-09-27T17:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Saving: Change default file path and automatically click yes</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7414298#M75326</link>
      <description>&lt;P&gt;Sort of... I guess? It's not I Logic or VBA to my knowledge its a preprogrammed plug in that I have no access to. It seems to run when the command manager says save (in cases of locked files or new files) or save as. I've played around with the dialogue events but it won't trigger with dialogue events so I couldn't use that.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 18:21:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-saving-change-default-file-path-and-automatically-click-yes/m-p/7414298#M75326</guid>
      <dc:creator>Thomas.Long</dc:creator>
      <dc:date>2017-09-27T18:21:41Z</dc:date>
    </item>
  </channel>
</rss>

