Hello,
I've got a script that is suppose to:
1. Open a drawing from the list provided in a table
2. Detect the sheet size of the open document(from the table list).
3. show a message box telling me what size the sheet is.
I can't get the sheet size to display properly. Any help guys?
''' Set a reference to the drawing document. ''' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim sheet1 as Sheet = oDrawDoc.Sheets("Sheet:1") Dim table As CustomTable = sheet1.CustomTables.Item(1) Dim oRow As Row ''' Iterate through the contents of the parts list. i = 1 While i <= table.Rows.Count oRow = table.Rows.Item(i) Dim oCell As Cell = oRow.Item(2) iDoc = iProperties.Value("Summary", "Category") & "\" & oCell.Value & ".idw" Dim oDoc As DrawingDocument = ThisApplication.Documents.Open(iDoc) Dim oSheet As Sheet = oDoc.ActiveSheet ' Dim MechCheck as String = oCell.Value If oSheet.Size = "B" Then MessageBox.Show("B", "Title") Else If oSheet.Size = "D" Then MessageBox.Show("D", "Title") End If 'you may also save And close this drawing document oDoc.Save oDoc.Close i = i+1 On Error Resume Next End While
Solved! Go to Solution.
Solved by VdVeek. Go to Solution.
This code only gives you a message box when the sheet size is an B or an D. If you want to see the sheet size, place after:
Dim oDoc As DrawingDocument = ThisApplication.Documents.Open(iDoc)
Dim oSheet As Sheet = oDoc.ActiveSheet
MessageBox.Show("Sheet Size = " & oSheet.Size, "Title")
Did you write this code yourself? What is it you want to accomplish with this code?
This code need some changes i think, but that depends on you needs.
Rob.
Well I kinda dumb down the code for the purpose of the message board becuase the only part I'm having trouble with is getting it to recognize the open drawing's sheet size. It opens the drawings and shows the message box but It is not showing the correct size. For example the sheet size will be "D" but the message box will show "B".
You actually helped me solve the problem. I was looking for a way to distinguish between "B" and "D" size by letter but oSheet.Size is a "Double" not a "String". So I used you sheet size message box to get the actual size and was able to apply that to the code I was writing. Thanks for the quick respone.