×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

My Macros stopped working with upgrade

My Macros stopped working with upgrade

My Macros stopped working with upgrade

(OP)
We updated to SW 2007 sp5 over the weekend and none of our macros are working any more. When I go to debug, it yellows out the Sub main () in the first code line. Does anyone have any ideas of what would be causing this or how I could fix it?

Here's the one I tried to run this morning.
-----------------------------------------------
Option Explicit

    Dim e As Long

    Dim w As Long


    Dim dxfver                  As String
    
    Dim swApp                   As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2
    Dim sPathName               As String

  
    
    Dim s12DXFPathName               As String
    Dim s14DXFPathName               As String
    
    Dim sPDFPathName               As String
    Dim sCNCPathName            As String
    
    Dim swDraw              As SldWorks.DrawingDoc
    Dim nErrors                 As Long

    Dim nWarnings               As Long

    Dim nRetval                 As Long
    Dim bRet                    As Boolean
    Dim bRet2                    As Boolean
    Dim bRet3                   As Boolean
    
    Dim Part                    As Object
    Dim SelMgr              As Object
    Dim boolstatus              As Boolean
    Dim longstatus          As Long, longwarnings As Long
    Dim Feature             As Object
____________________________________________________________

Sub main()

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc
    Set swDraw = swApp.ActiveDoc
    
    Set SelMgr = swModel.SelectionManager
   ' swModel.PrintDirect


     ' Strip off SolidWorks drawing file extension (.slddrw)

    ' and add DXF file extension (.dxf)

    sPathName = swModel.GetPathName

    sPathName = Left(sPathName, Len(sPathName) - 7)
    
    

    s12DXFPathName = sPathName + ".dxf"
    's14DXFPathName = sPathName + "_R14.dxf"
    
    sPDFPathName = sPathName + ".pdf"
    'sCNCPathName = sPathName + "_CNC.dxf"

    dxfver = swApp.GetUserPreferenceIntegerValue(swDxfVersion)

    
    swApp.SetUserPreferenceIntegerValue swDxfVersion, swDxfFormat_R12

    swApp.SetUserPreferenceIntegerValue swDxfOutputNoScale, 1
   

    bRet = swModel.SaveAs4(s12DXFPathName, _
         swSaveAsCurrentVersion, swSaveAsOptions_Silent, nErrors, _
            nWarnings)

    If bRet = False Then

        nRetval = swApp.SendMsgToUser2("Problems saving DXF file.", swMbWarning, swMbOk)

    End If
    
    bRet2 = swModel.SaveAs4(sPDFPathName, swSaveAsCurrentVersion, swSaveAsOptions_Silent, nErrors, _
            nWarnings)
    If bRet2 = False Then

        nRetval = swApp.SendMsgToUser2("Problems saving PDF file.", swMbWarning, swMbOk)

    End If
    
    'swApp.SetUserPreferenceIntegerValue swDxfVersion, swDxfFormat_R14
    
      'bRet3 = swModel.SaveAs4(s14DXFPathName, _
         'swSaveAsCurrentVersion, swSaveAsOptions_Silent, nErrors, _
            'nWarnings)

    'If bRet3 = False Then

        'nRetval = swApp.SendMsgToUser2("Problems saving DXF file.", swMbWarning, swMbOk)

    'End If
    
   'swDraw.ActivateSheet ("program")
    'bRet3 = swModel.SaveAs4(sCNCPathName, _
         swSaveAsCurrentVersion, swSaveAsOptions_Silent, nErrors, _
            nWarnings)
    
    'If bRet3 = False Then

       ' nRetval = swApp.SendMsgToUser2("Problems saving DXF file for programming.", swMbWarning, swMbOk)

    'End If

    ' Restore old setting
  swApp.SetUserPreferenceIntegerValue swDxfVersion, dxfver
  
    Set Part = swApp.ActiveDoc
    Set SelMgr = Part.SelectionManager
    Part.ViewZoomtofit2
    Part.Save2 False
    Set Part = Nothing
    sPathName = swModel.GetPathName
    swApp.CloseDoc (sPathName)

Boottmills
 

RE: My Macros stopped working with upgrade

What version did you upgrade from?

Try going to tools->References.  Check to see if any are missing, and re-order them a bit.  Sometimes you just have to force it to look for them again.

-handleman, CSWP (The new, easy test)

RE: My Macros stopped working with upgrade

(OP)
I upgraded from SP2 to SP5. I'm going to check the references and see what happens..I'll let y'all know!

Boottmills
 

RE: My Macros stopped working with upgrade

(OP)
YOU DA (HANDLE)MAN!

It did the trick! Thanks!

Boottmills
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources