Variable 'PPMK' is passed by reference before it has been assigned a value.

Hi everyone,

I'm getting these warnings when I go to build a Solidworks VSTA macro.

When I double-click the error message, it takes me to the SolidworksMacroStartup.vb file.  It looks like this file is automatically generated when I create the macro using the template installed with Solidworks,

The status line says the build succeeded, but when I attempt to Run the Macro, I

I'm treating this like a configuration issue.  Can anyone shed some light on why it's happening?

Thanks

John

SolidworksApi macros
Answers 8
IK
IK 2017-03-21 Best Answer

don't waste your time with VSTA

AJ
AJ 2017-03-21

I concur with ​

JB
JB 2017-03-21

Thanks for the feedback.  I'd be happy to do this using VBA except that it no longer supports the common dialog control and my current application requires the user to select an existing folder.

do you recommend VB.Net express edition instead?

DG
DG 2017-03-21
<p>John Burrill wrote:</p><p></p><p>do you recommend VB.Net express edition instead?</p>

Yes. I use VS Express 2013

NP
NP 2017-06-20

I am having the same problem "Variable 'ppmk' is passed by reference before it has been assigned a value."  in SolidWOrks 2016 VSTA VB macro and even a test macro with one line of code: MsgBox ("Hello")  in the SolidWorksMacro Sub Main() is generating following error.  Anybody has any idea what this could be and how do I solve it? Thanks.

comment imagecomment image
CC
CC 2017-06-20

Express version is fine as many here use it for writing add-in, not for .NET macro

CC
CC 2017-06-20

You can use a windows API function call to get existing folder

here is the code

<p>Public Const BIF_RETURNONLYFSDIRS = &H1</p><p>Public Const BIF_DONTGOBELOWDOMAIN = &H2</p><p>Public Const BIF_STATUSTEXT = &H4</p><p>Public Const BIF_RETURNFSANCESTORS = &H8</p><p>Public Const BIF_BROWSEFORCOMPUTER = &H1000</p><p>Public Const BIF_BROWSEFORPRINTER = &H2000</p><p>Public Const BIF_NEWDIALOGSTYLE = &H40</p><p>Declare PtrSafe Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As LongPtr, ByVal pszPath As String) As LongPtr</p><p>Declare PtrSafe Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As LongPtr</p><p>Public Function GetFolder(ByVal sTitle As String) As String</p><p></p><p></p><p>    Dim bInf As BROWSEINFO</p><p>    Dim retval As LongPtr</p><p>    Dim PathID As LongPtr</p><p>    Dim RetPath As String</p><p>    Dim Offset As Integer</p><p>   </p><p>    bInf.lpszTitle = sTitle</p><p>    bInf.ulFlags = BIF_NEWDIALOGSTYLE</p><p>    PathID = SHBrowseForFolder(bInf)</p><p>    RetPath = Space$(512)</p><p>   </p><p>    retval = SHGetPathFromIDList(ByVal PathID, ByVal RetPath)</p><p>   </p><p>    If retval Then</p><p>       </p><p>        Offset = InStr(RetPath, Chr$(0))</p><p>        GetFolder = Left$(RetPath, Offset - 1)</p><p>   </p><p>    End If</p><p></p><p></p><p>End Function</p>
JB
JB 2017-06-26

Thank you for that.  That will come in handy