4 Replies Latest reply on Oct 19, 2007 9:38 PM by SolidAir

    Macro won't run

    David Kingsley
      I have this routine that I wrote (with help from this site) and ithas been working fine until I got the new computer. Now it worksfor everybody but me!The only difference I can find is that I amrunning service pak 4.0 and they are using 2.4 or something likethat. It seems to work but does not insert the table.Is there somesetting I have missed or am I not holding the mouse right????Hereis the code.Probably won't paste right but I do not know how toattach it.Option ExplicitPrivate Declare Function FindWindow Lib"user32" Alias "FindWindowA" (ByVal_IpCIassName As String, ByVal IpWindowName As String) AsLongPrivate Declare Function DrawMenuBar Lib "user32"(ByVal Hwnd As Long) As LongPrivate Declare FunctionGetMenuItemCount Lib "user32" (ByVal hmenu As Long) AsLongPrivate Declare Function GetSystemMenu Lib "user32"(ByVal Hwnd As Long, _ByVal brevert As Long) As LongPrivate DeclareFunction RemoveMenu Lib _"user32" (ByVal hmenu As Long,ByVal _nposition As Long, ByVal wflags As Long) As LongPrivateConst MF_BYPOSITION = &H400Private Const MF_REMOVE =&H1000Dim VBresponceDim VBmsg As StringDim VBtitle AsStringPrivate Sub CmdCancel_Click()TxtBxRows.Text ="6"EndEnd SubPrivate Sub CmdCancel_MouseMove(ByVal ButtonAs Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y AsSingle)CmdCancel.SetFocusEnd SubPrivate Sub CmdOkay_Click()IfTxtBxRows.Value < 1 ThenMsgBox "Hey you need at LEASTone!"TxtBxRows.Text = "1"TxtBxRows.SetFocusExitSubEnd IfDim swApp As ObjectDim Part As ObjectDim SelMgr AsObjectDim boolstatus As BooleanDim longstatus As Long, longwarningsAs LongDim Feature As ObjectDim IntItms As IntegerDim IntAnchor AsIntegerDim IntTblRow As IntegerDim IntTblCol As IntegerDimLngRowCnt As LongDim StrTblName As StringIntItms = TxtBxRows.Value+ 1IntAnchor = 2' 1 = Top Right' 2 = Top Left' 3 = bottom Left' 4 =Bottom RightSet swApp = Application.SldWorksSet Part =swApp.ActiveDocSet SelMgr =Part.SelectionManagerswApp.ActiveDoc.ActiveView.FrameState =1StrTblName = "U:\Engineering\CEM Drawings\Solidworks\CEMTEMPLATES\BOM TEMP STD.sldtbt"Dim genTable As ObjectSetgenTable = Part.InsertTableAnnotation2(True, 1#, 1#, 2, StrTblName,IntItms, 7)If Not genTable Is Nothing ThengenTable.BorderLineWeight= 0genTable.GridLineWeight = 0IntTblCol = 0LngRowCnt =genTable.RowCountWhile LngRowCnt > 0genTable.Text(LngRowCnt,IntTblCol) = LngRowCntgenTable.Text(LngRowCnt, 2) = "THISONE"genTable.Text(LngRowCnt, 4) = "A36"LngRowCnt =LngRowCnt - 1WendEnd IfEndEnd SubPrivate SubCmdOkay_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,ByVal X As Single, ByVal Y As Single)CmdOkay.SetFocusEnd SubPrivateSub LblTxtBxRows_DblClick(ByVal Cancel AsMSForms.ReturnBoolean)Me.HideFrmMyFrst2.ShowEnd SubPrivate SubTxtBxRows_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)IfKeyAscii < 48 Or KeyAscii > 57 ThenKeyAscii = 0End IfEndSubPrivate Sub UserForm_Click()Me.HideVBtitle = "DumbASS!" ' just checkingVBmsg = "HEY! That hurts, Click theBUTTONS"VBresponce = MsgBox(VBmsg, vbOKOnly,VBtitle)Me.ShowEnd SubPrivate Sub UserForm_Initialize()Dim lngHwndAs LongDim lngmenu As LongDim IngCnt As LonglngHwnd =FindWindow(vbNullString, Me.Caption)lngmenu =GetSystemMenu(lngHwnd, 0)If lngmenu ThenIngCnt =GetMenuItemCount(lngmenu)Call RemoveMenu(lngmenu, IngCnt - 1,MF_REMOVE Or MF_BYPOSITION)Call DrawMenuBar(lngHwnd)EndIfTxtBxRows.Text = "6"TxtBxRows.SetFocusEnd SubTHANKSAGAIN!David
        • Macro won't run
          Hi David
          For pasting correctly your code look at Charle's answer in this thread : http://forum.solidworks.com/fo...catid=11&threadid=4974
          • Macro won't run
            SolidAir
            David,

            And please do not post the same question in multiple forums.

            SA
              • Macro won't run
                David Kingsley
                Ha, Ha, Ha, Now that's funny!I post the question in the group whereI got the help to make the thing and they tell me to post it here.So I do! Now you tell me NOT to post here. Okay!?But do you haveany ideas what the problem is?Or didn't anybody bother to actuallyread the question.I do NOT believe the code is the problem - Itworks on all computers but mine.Thanks anyway, and I will makeevery attempt not to double post. (sorry)David
                  • Macro won't run
                    SolidAir
                    David,

                    Actually I believe Charles said you should post it in the API forum not the User Interface forum but that is besides the point. I know someone will agrue with this but in my opinion, posting in more than one forum framents the answers or worst yet is answered by someone in one forum when the answer was already provided in another. I normally monitor all forums but not all questions. My advice is that if you change forums, you should either delete the post in the other forum or post the new thread.

                    SA