Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

My Macros stopped working with upgrade 1

Status
Not open for further replies.

boottmills

Mechanical
Feb 23, 2006
90
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
 
Replies continue below

Recommended for you

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)
 
I upgraded from SP2 to SP5. I'm going to check the references and see what happens..I'll let y'all know!

Boottmills
 
YOU DA (HANDLE)MAN!

It did the trick! Thanks!

Boottmills
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor