03-15-2024
08:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-15-2024
08:21 AM
Hello @A.Acheson ,
I am trying an approach, derived from the previous script and cant make it working. instead of trying to loop through each view, is it possible to define separate view variable in advance from the labels of the view, so as soon as we jump on the next row, we can change the partmember by excel values. If you think it is not a right approach, please provide the previous code with at least one view example, as I am struggling with the structure. the biggest challenge is to define the view then define the partfactroy for the member that is in that view. thanks again!
Sub Main Dim oCrossSecdoc As DrawingDocument = ThisApplication.ActiveDocument Dim oPathpdf As String = "C:\" 'Folder to save the drawings Dim oFactory As iPartFactory owbook = "C:" owSheet = "MASTER" GoExcel.Open(owbook,owSheet) Dim oView1Member As String Dim oView2Member As String Dim oView3Member As String Dim currentfilename As String Dim oView1 As DrawingView oView1 = oCrossSecdoc.ActiveSheet.DrawingViews(1) Dim oView2 As DrawingView oView1 = oCrossSecdoc.ActiveSheet.DrawingViews(2) Dim oView3 As DrawingView oView1 = oCrossSecdoc.ActiveSheet.DrawingViews(3) Dim oPartDoc1 As PartDocument oPartDoc1 = oView1.ReferencedDocumentDescriptor.ReferencedDocument ' Dim oPartDoc2 As PartDocument ' oPartDoc2 = oView2.ReferencedDocumentDescriptor.ReferencedDocument ' Dim oPartDoc3 As PartDocument ' oPartDoc3 = oView3.ReferencedDocumentDescriptor.ReferencedDocument Dim oDef1 As PartComponentDefinition oDef1 = oPartDoc1.ComponentDefinition Dim oDef2 As PartComponentDefinition ' oDef2 = oPartDoc2.ComponentDefinition Dim oDef3 As PartComponentDefinition ' oDef3 = oPartDoc3.ComponentDefinition Dim iPart1 As iPartFactory Dim iPart2 As iPartFactory Dim iPart3 As iPartFactory Dim oRow1 As iPartTableRow Dim oRow2 As iPartTableRow Dim oRow3 As iPartTableRow iPart1 = oDef1.iPartMember.ParentFactory ' iPart2 = oDef2.iPartMember.ParentFactory ' iPart3 = oDef3.iPartMember.ParentFactory Dim i As Integer 'start row to use Dim oStartRow As Integer oStartRow = 2 'number of rows to use Dim oRowlastcount As Long oRowlastcount = 5 For i = oStartRow To oRowlastcount oView1Member = GoExcel.CellValue(owbook, owSheet, "A" & i) oView2Member = GoExcel.CellValue(owbook, owSheet, "B" & i) oView3Member = GoExcel.CellValue(owbook, owSheet, "C" & i) currentfilename = GoExcel.CellValue(owbook, owSheet, "D" & i) MessageBox.Show(oView1Member, "partMember") ' MessageBox.Show(oView2Member, "partMember") ' MessageBox.Show(oView3Member, "partMember") ' MessageBox.Show(currentfilename, "Filename") oView1.ActiveMemberName = oView1Member oCrossSecdoc.SaveAs(oPathpdf & "\" & currentfilename & ".pdf", True) Next End Sub 'Sub ProcessView(drawView As DrawingView,partMember As String) ' Do something With the view Object ' MessageBox.Show(partMember, "partMember") ' MessageBox.Show(drawView.Name,"Drawing View Name") 'End Sub