- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
At the company I work for we have longer drawing packets for assemblies and field installations (5+ Pages) with many part details. For this reason we have to go through the BOM and under the "Note" Column fill out what sheet each part detail is on. For example if we have a base view on sheet 6 of a drawing we have to find that item in the BOM and custom enter "Sheet 6" (the sheet that the part is detailed on). I am looking to create a macro that will:
Go through each sheet
Get all the Base view/Drawing Views
Capture the model number (DisplayName) of each BaseView/Drawing View
Compare that to the BOM Field "MPN (our part number field)"
If it matches place "Sheet + Page # Drawing View came from" in the notes section.
This would save a lot of tedious engineering grunt work. I am just starting out on this task, and to do this I am using a series of For Each X in Y loops. I keep getting the error "Object Required", I know what it means, but I do not see why it is happening. Below I am attaching screen shots of the error box and highlighted line that is giving me the error. When I hover over the highlighted line is gives me the dialogue "DrawingViews = Empty" but I am not sure why because I have 3 Drawing views on the first sheet. My full thus far is as followed. (Note it is nowhere near complete)
Public Sub SheetNumber()
'Get the active document and store it
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oActSheet As Sheet
Set oActSheet = oDrawDoc.ActiveSheet
Dim oActPartList As PartsList
Set oActPartList = oActSheet.PartsLists.Item(1)
Dim oSheets As Sheets
Set oSheets = oDrawDoc.Sheets
Dim oSheet As Sheet
For Each oSheet In oSheets
Dim oDrawingViews As DrawingViews
Set oDrawingViews = oSheet.DrawingViews
Dim oDrawingView As DrawingView
For Each oDrawingView In DrawingViews
Dim oRefDoc As ReferencedFileDescriptor
Set oRefDoc = oDrawingView.ReferencedDocumentDescriptor
Dim oRefName As String
oRefName = oRefDoc.DisplayName
oRefNameLeft = Left(oRefName, Len(oRefName) - 4)
MsgBox ("Ref Name Left = " & oRefNameLeft)
Next
Next
End Sub
Additionally, if anyone has done something like this before or something similar and could provide direction or give help in creating this macro that would be greatly appreciated!
Solved! Go to Solution.