2 Replies Latest reply on Jan 13, 2016 1:01 PM by Deepak Gupta

    Macro Compile Error Help

    Jason George

      I have 2 macros that work very similar to one another that I have been working on updating for VBA 7.  One macro creates a pdf of the current open drawing, the other creates drawings of everything currently in SoildWorks current working directory based on pdm life cycle state criteria.  They share the same section of code for the windows save location dialog box.  I was able to update one of the macros just find and it can run pre and post sw2013 without any issues.  For some reason I can't get the other one to work.  If someone could offer some insight that would be great.

        • Re: Macro Compile Error Help
          Jason George

          Here is the section of code where the macro and been edited and hangs up on. "BIF_RETURNONLYFSDIRS" gets highlighted yellow with the compile error.

           

          Option Explicit

           

           

          #If vba7 Then

           

           

          Private Const BIF_RETURNONLYFSDIRS As LongPtr = &H1

          Private Const BIF_DONTGOBELOWDOMAIN As LongPtr = &H2

          Private Const BIF_RETURNFSANCESTORS As LongPtr = &H8

          Private Const BIF_BROWSEFORCOMPUTER As LongPtr = &H1000

          Private Const BIF_BROWSEFORPRINTER As LongPtr = &H2000

          Private Const BIF_BROWSEINCLUDEFILES As LongPtr = &H4000

          Private Const MAX_PATH As LongPtr = 260

           

           

          #Else

           

           

          Private Const BIF_RETURNONLYFSDIRS As Long = &H1

          Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2

          Private Const BIF_RETURNFSANCESTORS As Long = &H8

          Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000

          Private Const BIF_BROWSEFORPRINTER As Long = &H2000

          Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000

          Private Const MAX_PATH As Long = 260

           

           

          #End If

           

           

          Dim swApp                   As SldWorks.SldWorks

          Dim swModel                 As SldWorks.ModelDoc2

          Dim bRet                    As Boolean

          Dim nErrors                 As Long

          Dim nWarnings               As Long

          Dim SaveAsPath              As String

          Dim nResponse               As Integer

          Dim Response                As String

          Dim instance                As ISldWorks

          Dim value                   As String

          Dim swfilename              As String

           

           

           

           

          Function BrowseFolder(Optional Caption As String, _

              Optional InitialFolder As String) As String

           

           

          Dim SH As Shell32.Shell

          Dim F As Shell32.folder

           

           

          Set SH = New Shell32.Shell

          Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, InitialFolder = "Desktop")

          If Not F Is Nothing Then

              BrowseFolder = F.Items.Item.Path

          End If

           

           

          End Function

            • Re: Macro Compile Error Help
              Deepak Gupta

              Remove following lines and #End IF (make sure to keep the lines between #Else and #End IF

              #If vba7 Then

               

               

              Private Const BIF_RETURNONLYFSDIRS As LongPtr = &H1

              Private Const BIF_DONTGOBELOWDOMAIN As LongPtr = &H2

              Private Const BIF_RETURNFSANCESTORS As LongPtr = &H8

              Private Const BIF_BROWSEFORCOMPUTER As LongPtr = &H1000

              Private Const BIF_BROWSEFORPRINTER As LongPtr = &H2000

              Private Const BIF_BROWSEINCLUDEFILES As LongPtr = &H4000

              Private Const MAX_PATH As LongPtr = 260

               

               

              #Else

               

              #End If