Paste this code into a module and give it a try.
Option Explicit
Option Compare Text
Public Const WM_COPYDATA = &H4A
Type CopyStringDataStruct
dwData As Long
cbData As Long
lpData As String
End Type
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As
Long, _
ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As
Long
Public Sub SndCmd(Cmd As String)
Dim n As Integer, ch As String, Cmd2 As String
Dim WinMsg As CopyStringDataStruct
Dim hWnd As Long
Cmd2 = ""
For n = 1 To Len(Cmd)
ch = Mid$(Cmd, n, 1)
If ch = "^" Then
n = n + 1
If n <= Len(Cmd) Then
ch = StrConv(Mid$(Cmd, n, 1), vbUpperCase)
ch = Chr$(Asc(ch) - 64)
Else
ch = ""
End If
End If
Cmd2 = Cmd2 & ch
Next n
If Cmd2 <> "" Then
Cmd2 = Cmd2 & vbNullChar
hWnd = FindWindow(vbNullString, ThisDrawing.Application.Caption)
If hWnd <> 0 Then
WinMsg.dwData = CLng(1)
WinMsg.cbData = Len(Cmd2) + 1
WinMsg.lpData = Cmd2
SendMessage hWnd, WM_COPYDATA, hWnd, WinMsg
Else
MsgBox "Could Not Find AutoCAD Window."
End If
End If
End Sub
-Josh
John McDowell wrote:
> I want to send a command to AutoCad R.14.01 from VB6. How can I accomplish
> this?
>
> Cheers, John.