Try these codes and if they work, then you can modify as required.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim Value As String
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Value = swModel.CustomInfo2("", "NUMBER")
First, I assume you are using .NET VSTA macros, not VBA, right?
Next, you are getting the custom property manager, but not using it to get the custom property. CustomInfo2 is a really, really old API. Not that it doesn't work, but the CustomPropertyManager is the newer, more powerful/flexible way to get to them.
Looks like you've pulled single lines out of a longer program there. Are these the specific lines that give you errors now that didn't in 2013?
Yes on all points. Below is the complete code up to the part that is not working.
In fact after reading your post I realized that the code did utilize custompropertymanager but then called Custominfo2! Ha!
I have made the move to a Get but it still does not work. Also, the Msgbox does not work either. It does not even come up so there must be something else wrong. This tool does properly update the property of the part so I know it is working in general.
Private Sub UserForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim swapp As SldWorks
Dim Doc As ModelDoc2
Dim CustProp As CustomPropertyManager
Dim DocExt As ModelDocExtension
Dim val As String = ""
Dim valout As String = ""
Dim boolstatus As Boolean
Dim Title As String
Dim i As Integer = 0
Dim j As Integer = 0
swapp = GetObject(, "SldWorks.Application")
Doc = swapp.ActiveDoc
DocExt = Doc.Extension
CustProp = DocExt.CustomPropertyManager("")
Title = Doc.GetTitle
MsgBox("This is the Doc Number: " & CustProp.Get("Number") & " " & CustProp.Count)
txtDocNumber.Text = CustProp.Get("Number")
txtDescription.Text = Doc.CustomInfo2("", "TITLE1").ToUpper
You aren't doing any checks for things like there not being an active document.
It's possible that GetObject is connecting to a background session of SolidWorks where there is no document open.
Put some checks in like::
If Doc Is Nothing Then
swApp.SendMsgToUser2("No active document.", swMessageBoxIcon_e.swMbStop, swMessageBoxBtn_e.swMbOk)
and check if it's a part/assembly or drawing:
If Doc.GetType <> 1 Then
swApp.SendMsgToUser2("No active PART document.", swMessageBoxIcon_e.swMbStop, swMessageBoxBtn_e.swMbOk)
Thanks for the help!!
The first reply fixed things. VS was not updating properly and I had to reboot. Once I rebooted I was able to use your first reply to fix it all.