AnsweredAssumed Answered

Macro won't run

Question asked by David Kingsley on Oct 10, 2007
Latest reply on Oct 19, 2007 by SolidAir
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

Outcomes