OK This is what i have. It's My code included with yours, but it's not bringing up the dialog box to save. it does however still save my stuff. but it doesn't allow me to pick the location i want it to save to.
The "oPartslist.export" part of my code is how it saves. I'm still new at vba so i dont quite fully understand what your caode is telling me. Or how it working in conjunction with mine. Any thoughts?
Sub Main()
'get the path and name of the drawing file
path_and_name = ThisDoc.PathAndFileName(False) ' without extension
'define oDoc
oDoc = ThisDoc.Document
'specify the drawing sheet
oSheet = oDoc.Sheets("Sheet:1") ' sheet by name
'oSheet = oDoc.Sheets(1) ' first sheet
' say there is a Partslist on the sheet.
oPartslist = oSheet.PartsLists(1)
' create a new NameValueMap object
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
'-------------Start of ilogic ------------------------------------------------
'specify the columns to export
oOptions.Value("ExportedColumns") = "ITEM;QTY;M1 PART ID;REV;PART DESCRIPTION;WIDTH;LENGTH;PERIMETER;DETAIL;BLOCK WT;FINISH WT"
'specify the start cell
oOptions.Value("StartingCell") = "A1"
'specify the XLS tab name
'here the file name is used
oOptions.Value("TableName") = "BILL OF MATERIALS"
oOptions.Value("ApplyCellFormatting") = True
'choose to autofit the column width in the xls file
oOptions.Value("AutoFitColumnWidth") = True
' export the Partslist to Excel with options
oPartslist.Export(path_and_name & ".xls", _
PartsListFileFormatEnum.kMicrosoftExcel, oOptions)
'-------------End of ilogic ------------------------------------------------
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "L1")= "Total Surface Area"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "L2")= iProperties.Value("Custom", "Total_Surface_Area")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "M1")= "Total Weight"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "M2")= iProperties.Value("Custom", "Assembly_Weight")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "N1")= "QTY of Assemblies"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "N2")= iProperties.Value("Custom", "QTY REQ'D")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "O1")= "Tag#"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "O2")= iProperties.Value("Project", "Part Number")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "P1")= "Customer"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "P2")= iProperties.Value("Custom", "Client")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "Q1")= "Customer PO#"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "Q2")= iProperties.Value("Custom", "Customer PO#")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "R1")= "Project"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "R2")= iProperties.Value("Custom", "Project")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "S1")= "Eng Det#"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "S2")= iProperties.Value("Custom", "Engineers Detail#")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "T1")= "DMI JOB#"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "T2")= iProperties.Value("Custom", "DMI JOB#")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "U1")= "Fabrication Operations"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "U2")= iProperties.Value("Custom", "Operations")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "V1")= "Weld Procedure #1"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "V2")= iProperties.Value("Custom", "Weld Procedure# 1")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "W1")= "Weld Procedure #2"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "W2")= iProperties.Value("Custom", "Weld Procedure# 2")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X1")= "Delta Total LNFT of Weld"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X2")= iProperties.Value("Custom", "Delta LNFT of Weld")
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X3")= "Shop Total LNFT of Weld"
GoExcel.CellValue(path_and_name, "BILL OF MATERIALS", "X4")= iProperties.Value("Custom", "Shop LNFT of Weld")
End Sub
Private Function FileBrowse(Save As Boolean)
Dim oFileDlg As FileDialog
' Create a new FileDialog object.
Call ThisApplication.CreateFileDialog(oFileDlg)
' Define the filter to select part and assembly files or any file.
With oFileDlg
'"
' Define the part and assembly files filter to be the default filter.
.FilterIndex = 1
.MultiSelectEnabled = False
' Set the title for the dialog.
' Set the initial directory that will be displayed in the dialog.
oFileDlg.InitialDirectory = ThisApplication.FileOptions.ProjectsPath
' Set the flag so an error will be raised if the user clicks the Cancel button.
.CancelError = True
' Show the open dialog. The same procedure is also used for the Save dialog.
' The commented code can be used for the Save dialog.
On Error Resume Next
If Save = True
.Filter = "Excel Files (*.xlsx)| *.xlsx"
.DialogTitle = "Specify New Save Location and Name"
.ShowSave
Else
'.Filter = "Inventor Files (*.iam;*.ipt;*.idw;*.dwg)|*.iam;*.ipt;*.idw;*.dwg|​All Files (*.*)|*.*"
.Filter = "Excel Files (*.xlsx)| *.xlsx"
.DialogTitle = "Select Excel File To Use As Drawing List"
.ShowOpen
End If
oFileDlg.ShowSave
End With
If Err.Number <> 0 Then
MsgBox("Error Exists")
ElseIf Not oFileDlg.FileName = "" Then
Dim fNames As Object
fNames = Split(oFileDlg.FileName, "|")
Dim curName As Object
Dim lstSource As Object
For Each curName In fNames
lstSource.AddItem(curName)
Next curName
End If
Return oFileDlg.FileName
End Function