Thread: appactivate
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Philip Kopf Philip Kopf is offline
external usenet poster
 
Posts: 4
Default appactivate

Because it is the other application that I am gtathering
data from and it requires me to appactivate it so I can
see it to dynamically get some dimensional data from
Autocad. Once I get that data I am writing it back to
excel. Then I want to have excel do some other work for
me. But I can't get the excel spreadsheet back on top.
-----Original Message-----
Why appactivate Autocad in the first place. Does your

code fail if you
remove that line.

--
Regards,
Tom Ogilvy

"Philip Kopf"

wrote in message
...
I have tried to use the appactivate command but can not
get the focus back to excel after I gather info from
another application. Attached is my code. Can anyone
tell me how to get excel back on top?

Private Sub CommandButton2_Click()
'
Dim ACAD As Object
Dim MS As Object
Dim myappid
Set ACAD = GetObject(, "AUTOCAD.APPLICATION")
Set MS = ACAD.activedocument.ModelSpace
AppActivate "autodesk"
'
Dim llpc As Variant
Dim urpc As Variant
Dim htft, htin, wdft, wdin
'
With ACAD.activedocument.Utility
llpc = .GetPoint(, vbCr & "Pick the Lower Left
Panel Corner: ")
urpc = .GetPoint(llpc, vbCr & "Pick the Upper
Right Panel Corner: ")
End With
'
With Worksheets("A")
'
'
.Range("c22").Value = 0
.Range("d22").Value = 0
.Range("c21").Value = 0
.Range("d21").Value = 0
'
wdft = Application.WorksheetFunction.RoundDown
((urpc(0) - llpc(0)) / 12, 0)
wdin = (urpc(0) - llpc(0)) - (wdft * 12)
htft = Application.WorksheetFunction.RoundDown
((urpc(1) - llpc(1)) / 12, 0)
htin = (urpc(1) - llpc(1)) - (htft * 12)
'
.Range("c21").Value = htft
.Range("d21").Value = htin
.Range("c22").Value = wdft
.Range("d22").Value = wdin
'
End With
AppActivate "Microsoft Excel"
End Sub



.