Message 1 of 2

Not applicable
11-14-2019
03:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've tried reading all the related posts on here regarding the 'Object Reference Not Set' error but nothing seems to be working and I'm running out of ideas. I don't get any information regarding where this error is occuring and having tried the MsgBox("Here") method I've found that the code fails during the bold section. Any help would be much appreciated.
Dim oDoc As DrawingDocument Dim oSheet As Sheet Dim oTB1 As TitleBlock Dim titleDef As TitleBlockDefinition Dim oPrompt Dim title As String Dim titleVal As String Dim oCurrentSheet Dim oTitleBlock As TitleBlock Dim oTextBoxes As TextBoxes Dim oTextBox As TextBox Dim oPromptEntry Dim oPtDoc As String oDoc = ThisApplication.ActiveDocument oCurrentSheet = oDoc.ActiveSheet.Name oSheet = oDoc.Activesheet oTB1 = oSheet.TitleBlock titleDef = oTB1.Definition 'For Each defText As TextBox In titleDef.Sketch.TextBoxes ' If defText.Text = "<TITLE>" Then ' oPrompt = defText ' Exit For ' End If 'Next 'title = oTB1.GetResultText(oPrompt) 'iProperties.Value("Summary", "Title") = title MsgBox("Here") ' For Each oSheet In oDoc.Sheets ' oDoc.Sheets.Item(1).Activate ' oTitleBlock = oSheet.TitleBlock ' oTextBoxes = oTitleBlock.Definition.Sketch.TextBoxes ' For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes ' Select oTextBox.Text ' Case "<TITLE>" ' oPromptEntry = oTitleBlock.GetResultText(oTextBox) ' iProperties.Value("Summary", "Title") = oPromptEntry ' End Select ' Next ' Next ' oDoc.Sheets.Item(oCurrentSheet).activate ' ddoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) ' iProperties.Value(ddoc, "Summary", "Title") = iProperties.Value("Summary", "Title") oPtDoc = oDoc.ActiveSheet.DrawingViews(1).Name modelName = IO.Path.GetFileName(ActiveSheet.View(oPtDoc).ModelDocument.FullFileName) iProperties.Value(modelName, "Summary", "Title") = "Test" iLogicVb.UpdateWhenDone = True Logger.Debug("Title: " & title) iLogicForm.Show("Save Drawing") If saved = True Then ThisDoc.Document.saveasinventordwg("C:\VaultWS\Designs\Umbilical\Workshop Equipment\HHAM\Closing Die\Test" & title & ".dwg", True) oPath = ThisDoc.Path oFileName = ThisDoc.FileName(False) 'without extension oRevNum = iProperties.Value("Project", "Revision Number") oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oDocument = ThisApplication.ActiveDocument oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium 'If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 2 'oOptions.Value("Custom_End_Sheet") = 4 'End If 'get PDF target folder path oFolder = Left(oPath, InStrRev(oPath, "\")) & "PDF" 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFileName & " Rev" & oRevNum & ".pdf" 'Publish document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) End If
Solved! Go to Solution.