#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default appactivate

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default appactivate

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
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



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
appactivate Philip Kopf Excel Programming 3 August 23rd 04 05:06 AM
Running a .bat file via AppActivate Kevin Excel Programming 1 April 10th 04 10:53 PM
AppActivate problem when called twice SuperJas Excel Programming 0 March 3rd 04 06:41 AM
AppActivate trouble... David Kay Excel Programming 1 December 11th 03 12:17 AM
appactivate sendkeys not working with accelerator RB Smissaert Excel Programming 4 August 12th 03 08:31 PM


All times are GMT +1. The time now is 07:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"