user-0 提问: 求大神指点以下代码

回复:
user: user-1
content: 搜“VBA for AutoCAD”？

user: user-0
content: 老师，我是做结构设计的，画图画多了想提高效率学习点CAD的编写插件，但是入不得门。

user: user-1
content: 代码功能归根结底不是别人帮自己看或讲解或注释出来的；而是被自己静下心来花足够长的时间和精力亲自动手单步或设断点或对执行到某步获得的中间结果显示或写到日志文件中一步一步分析出来的。 提醒：再牛×的老师也无法代替学生自己领悟和上厕所！  注释掉所有On Error Resume Next语句，在VB6 IDE中运行， 出错后点击调试，光标会停在出错的那条语句处， 或者 事先在怀疑可能有逻辑错误的语句处设置断点，运行经过断点时中断，  此时可以在立即窗口中使用 ?变量名 或 ?函数名(函数参数) 或 过程名(参数) 辅助调试。

user: user-0
content: 我的QQ896079148

user: user-0
content: '打开文件   Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Private Const SW_SHOW = 5 '-------------------切换线程------------- Private Declare PtrSafe Function GetWindowThreadProcessId Lib "user32" _     (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare PtrSafe Function AttachThreadInput Lib "user32" _     (ByVal idAttach As Long, ByVal idAttachTo As Long, ByVal fAttach As Long) As Long Private Declare PtrSafe Function GetForegroundWindow Lib "user32" () As Long Private Declare PtrSafe Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare PtrSafe Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long Private Declare PtrSafe Function ShowWindow Lib "user32" _     (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long  'Private Const SW_SHOW = 5  '与打开文件里面的重复了，这里取消 Private Const SW_RESTORE = 9 '-------------------切换线程------------- Sub 批量替换()  Dim i As Integer    On Error Resume Next     FileCopy ThisDrawing.Path & "\PiLiangTiHuan.dll", "C:\WINDOWS\system32\PiLiangTiHuan.dll"   Shell "regsvr32   /s   PiLiangTiHuan.dll"       Err.Clear        Dim xlApp As Object, xlSheet As Object            Set xlApp = GetObject(, "Excel.Application")        If Err Then      Err.Clear     Set xlApp = GetObject(, "ET.Application")                 End If        If Err Then        Err.Clear             ShellExecute MyhWnd, "open", ThisDrawing.Path & "\TT_AutoCAD文字自动替代.xls", vbNullString, vbNullString, SW_SHOW       GoTo QueDingSheet          End If          If xlApp.Workbooks.Count > 0 Then     For i = 1 To xlApp.Workbooks.Count                           If InStr(xlApp.Workbooks(i).Name, "TT_AutoCAD文字自动替代") > 0 Then           Set xlSheet = xlApp.Workbooks(i).ActiveSheet           GoTo QueDingSheet                    End If      Next          End If          Err.Clear           ShellExecute MyhWnd, "open", ThisDrawing.Path & "\TT_AutoCAD文字自动替代.xls", vbNullString, vbNullString, SW_SHOW            QueDingSheet:                  ForceForegroundWindow Application.hwnd         Dim objForm As Object      ' New PiLiangTiHuan.TiHuan        Set objForm = CreateObject("PiLiangTiHuan.TiHuan")     Set objForm.Application = Application          DoEvents          objForm.ShowFormMain       Err.Clear     End Sub  Private Sub AcadDocument_Activate()   On Error Resume Next  FileCopy ThisDrawing.Path & "\PiLiangTiHuan.dll", "C:\WINDOWS\system32\PiLiangTiHuan.dll"   Shell "regsvr32   /s   PiLiangTiHuan.dll"       Err.Clear    批量替换 End Sub Public Function ForceForegroundWindow(ByVal hwnd As Long) As Boolean    Dim ThreadID1 As Long    ' 线程ID    Dim ThreadID2 As Long    ' 线程ID    Dim nRet As Long        ' 如果指定的窗体已经在前台，不做任何操作    If hwnd = GetForegroundWindow() Then       ForceForegroundWindow = True    Else       ' 首先获得指定窗体相关的线程和当前前台窗口所在的线程       ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow, ByVal 0&)       ThreadID2 = GetWindowThreadProcessId(hwnd, ByVal 0&)              ' 通过共享输入状态，两个线程分享当前窗口       If ThreadID1 <> ThreadID2 Then          Call AttachThreadInput(ThreadID1, ThreadID2, True)          nRet = SetForegroundWindow(hwnd)          Call AttachThreadInput(ThreadID1, ThreadID2, False)       Else          nRet = SetForegroundWindow(hwnd)       End If              ' 恢复和重画       If IsIconic(hwnd) Then          Call ShowWindow(hwnd, SW_RESTORE)       Else          Call ShowWindow(hwnd, SW_SHOW)       End If              ' 精确地返回函数执行结果       ForceForegroundWindow = CBool(nRet)    End If End Function     'Private Sub AcadDocument_EndCommand(ByVal CommandName As String)    '  On Error GoTo errhand    'If CommandName = "VBALOAD" Or CommandName = "VBAMAN" Or CommandName = "APPLOAD" Or CommandName = "COMMANDLINE" Then  '   Dim objForm As New PiLiangTiHuan.TiHuan  '   Set objForm.Application = Application  '   objForm.ShowFormMain 'End If  'errhand: 'If Err.Number = 0 Then   ' Else      '  MsgBox Err.Description & Err.Number        '  Err.Clear      'End If    'End Sub Private Sub AcadDocument_BeginDoubleClick(ByVal PickPoint As Variant)   批量替换 End Sub 帮我看下这个吧

user: user-2
content: VB上学那会学过，早忘了

user: user-0
content: VB，能加你QQ么？现在程序我网上已经找到了，但是调试的时候老是显示.hwnd处类型不匹配。如何破

user: user-3
content: 这是什么语言的语法？看着不是C语言的