Hallo
Ik heb een macro gebruikt die door een andere gebruiker is gepost.
Ik heb snel een bug en ik geef toe dat ik geen macrospecialist ben. Het programma crasht met een Run-Tume-fout 91 (objectvariabele met blokvariabele niet ingesteld) in de Set-instructie swBOMFeature = swBOMAnnotation.BomFeature vetgedrukt
Kunt u mij vertellen waar ik de fout in ga en hoe ik mijn probleem kan oplossen?
Bij voorbaat dank
Sub hoofd()
Dim xlApp als Excel.Application
Stel xlApp in = Nieuwe Excel.Toepassing
Dim wbk als Excel.Workbook
Dim sht als Excel.Werkblad
Met xlApp
. Zichtbaar = Waar
Stel wbk in = . Werkmappen.Toevoegen
Stel sht in = wbk. Actief blad
Eindigen met
Dim swApp als SldWorks.SldWorks
Dim swModel als SldWorks.ModelDoc2
Dim swModelDocExt als SldWorks.ModelDocExtension
Dim swBOMAnnotatie als SldWorks.BomTableAnnotation
Dim swBOMFeature As SldWorks.BomFeature
Dim boolstatus als Booleaanse
Dim BomType zo lang
Dim configuratie als tekenreeks
Dim TemplateName als tekenreeks
Dim TableTemplate als tekenreeks
Stel swApp = Toepassing.SldWorks in
Stel swModel = swApp.ActiveDoc in
Stel swModelDocExt = swModel.Extension in
TemplateName = "C:\Gebruikers\sal1chl\Desktop\test_nomenclature.sldbomtbt"
BomType = swBomType_TopLevelOnly
Stel swBOMAnnotatie in = swModelDocExt.InsertBomTable3(TemplateName, 0, 0, BomType, Configuratie, False, swNumberingType_Detailed, True)
Stel swBOMFeature = swBOMAnnotation.BomFeature in
swModel.ForceRebuild3 Waar
Dim NumCol zo lang
Dim NumRow zo lang
Dim ik zo lang
Zon J Zo lang
NumCol = swBOMAnnotatie.ColumnCount
NumRow = swBOMAnnotatie.RowCount
Voor I = 0 om te numrowen
Voor J = 0 TB NumCol
Sht. Cellen (I + 1, J + 1). Waarde = swBOMAnnotatie.Tekst(I, J)
Volgende J
Volgende I
boolstatus = swModelDocExt.SelectByID2(swBOMFeature.GetFeature.Description, "BOMFEATURE", 0, 0, 0, True, 0, Nothing, 0)
swModel.EditDelete
swModel.ForceRebuild3 Waar
Dim config As SldWorks.Configuration
Dim cusPropMgr As SldWorks.CustomPropertyManager
Dim lRetVal zo lang
Dim ValOut als snaar
Dim ResolvedValOut als tekenreeks
Dim wasOpgelost als Booleaanse
Dim nNbrProps zo lang
Dim vPropNames als variant
Dim vPropTypes als variant
Dim vPropValues als variant
Dim opgelost als variant
Dim custPropType zo lang
Dim K zo lang
Dim NameProperty als tekenreeks
Stel cusPropMgr in = swModelDocExt.CustomPropertyManager("")
nNbrProps = cusPropMgr.Count
vPropNames = cusPropMgr.GetNames
Voor K = 0 Naar nNbrProps - 1
cusPropMgr.Get2 vPropNames(K), ValOut, ResolvedValOut
custPropType = cusPropMgr.GetType2(vPropNames(K))
Als vPropNames(K) = "CARTOONIST" Dan
PropertyName = OpgelostValOut
Einde als
Volgende K
Dim pad als snaar
path = Over ("GEBRUIKERSPROFIEL") & "\Desktop\" & swModel.GetTitle & "-" & PropertyName & ".xls"
Met xlApp
wbk. Pad OpslaanAls
wbk. Sluiten
. Verlaten
Eindigen met
Einde Sub