Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Shell Problem

I am having trouble getting Paint started:

Sub paint1()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
AppActivate ReturnValue
End Sub

Raises a run time error 5

Sub paint2()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
MsgBox (ReturnValue)
AppActivate ReturnValue
End Sub

Works just fine. Why do I need the MsgBox() before the AppActivate??

--
Gary''s Student - gsnu200755
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Shell Problem

I've never totally understood the why's, and the first time i worked with it
i tried it your way, but if you just shell without the returnvalue= you get
an error, take off the paren and it all works beautifully
Shell "C:\WINDOWS\system32\mspaint.exe", 1

that is the only line you need in the whole thing.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Gary''s Student" wrote:

I am having trouble getting Paint started:

Sub paint1()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
AppActivate ReturnValue
End Sub

Raises a run time error 5

Sub paint2()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
MsgBox (ReturnValue)
AppActivate ReturnValue
End Sub

Works just fine. Why do I need the MsgBox() before the AppActivate??

--
Gary''s Student - gsnu200755

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Shell Problem

Thanks for your response. Its the AppActivate that is failing. It need it
to make Paint the active application. If I omit the AppActivate, any
subsequent commands I send end up going to Excel rather than Paint.

I need them to go to Paint


b.t.w. I don't have this problem running Word from Excel.
--
Gary''s Student - gsnu200755


"John Bundy" wrote:

I've never totally understood the why's, and the first time i worked with it
i tried it your way, but if you just shell without the returnvalue= you get
an error, take off the paren and it all works beautifully
Shell "C:\WINDOWS\system32\mspaint.exe", 1

that is the only line you need in the whole thing.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Gary''s Student" wrote:

I am having trouble getting Paint started:

Sub paint1()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
AppActivate ReturnValue
End Sub

Raises a run time error 5

Sub paint2()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
MsgBox (ReturnValue)
AppActivate ReturnValue
End Sub

Works just fine. Why do I need the MsgBox() before the AppActivate??

--
Gary''s Student - gsnu200755

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Shell Problem

I see where you get those examples in the help but they are wrong, they error
if you run them (as you know), just give the program focus with the ,1 at the
end of the shell script
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Gary''s Student" wrote:

Thanks for your response. Its the AppActivate that is failing. It need it
to make Paint the active application. If I omit the AppActivate, any
subsequent commands I send end up going to Excel rather than Paint.

I need them to go to Paint


b.t.w. I don't have this problem running Word from Excel.
--
Gary''s Student - gsnu200755


"John Bundy" wrote:

I've never totally understood the why's, and the first time i worked with it
i tried it your way, but if you just shell without the returnvalue= you get
an error, take off the paren and it all works beautifully
Shell "C:\WINDOWS\system32\mspaint.exe", 1

that is the only line you need in the whole thing.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Gary''s Student" wrote:

I am having trouble getting Paint started:

Sub paint1()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
AppActivate ReturnValue
End Sub

Raises a run time error 5

Sub paint2()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
MsgBox (ReturnValue)
AppActivate ReturnValue
End Sub

Works just fine. Why do I need the MsgBox() before the AppActivate??

--
Gary''s Student - gsnu200755

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Shell Problem

First, thank you very much for you help. I do appreciate your interest &
willingness to help.

Here is a sample of what is happening:

Sub pai()
Dim ReturnValue, i As Integer
For i = 1 To 4
Cells(1, i).Value = i
Next
Range("A1:D1").CopyPicture Appearance:=xlScreen, Format:=xlPicture
Shell "C:\WINDOWS\system32\mspaint.exe", 1
SendKeys "^v", True
End Sub

1. the cells are filled
2. the picture is copied
3. Paint is activated
4. CNTRL-v is issued

Sadly the CNTRL-v is accepted by Excel rather than Paint.
--
Gary''s Student - gsnu200755


"John Bundy" wrote:

I see where you get those examples in the help but they are wrong, they error
if you run them (as you know), just give the program focus with the ,1 at the
end of the shell script
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Gary''s Student" wrote:

Thanks for your response. Its the AppActivate that is failing. It need it
to make Paint the active application. If I omit the AppActivate, any
subsequent commands I send end up going to Excel rather than Paint.

I need them to go to Paint


b.t.w. I don't have this problem running Word from Excel.
--
Gary''s Student - gsnu200755


"John Bundy" wrote:

I've never totally understood the why's, and the first time i worked with it
i tried it your way, but if you just shell without the returnvalue= you get
an error, take off the paren and it all works beautifully
Shell "C:\WINDOWS\system32\mspaint.exe", 1

that is the only line you need in the whole thing.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Gary''s Student" wrote:

I am having trouble getting Paint started:

Sub paint1()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
AppActivate ReturnValue
End Sub

Raises a run time error 5

Sub paint2()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
MsgBox (ReturnValue)
AppActivate ReturnValue
End Sub

Works just fine. Why do I need the MsgBox() before the AppActivate??

--
Gary''s Student - gsnu200755



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Shell Problem

Dang know it all Chip!
http://www.cpearson.com/excel/ShellAndWait.htm
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Gary''s Student" wrote:

First, thank you very much for you help. I do appreciate your interest &
willingness to help.

Here is a sample of what is happening:

Sub pai()
Dim ReturnValue, i As Integer
For i = 1 To 4
Cells(1, i).Value = i
Next
Range("A1:D1").CopyPicture Appearance:=xlScreen, Format:=xlPicture
Shell "C:\WINDOWS\system32\mspaint.exe", 1
SendKeys "^v", True
End Sub

1. the cells are filled
2. the picture is copied
3. Paint is activated
4. CNTRL-v is issued

Sadly the CNTRL-v is accepted by Excel rather than Paint.
--
Gary''s Student - gsnu200755


"John Bundy" wrote:

I see where you get those examples in the help but they are wrong, they error
if you run them (as you know), just give the program focus with the ,1 at the
end of the shell script
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Gary''s Student" wrote:

Thanks for your response. Its the AppActivate that is failing. It need it
to make Paint the active application. If I omit the AppActivate, any
subsequent commands I send end up going to Excel rather than Paint.

I need them to go to Paint


b.t.w. I don't have this problem running Word from Excel.
--
Gary''s Student - gsnu200755


"John Bundy" wrote:

I've never totally understood the why's, and the first time i worked with it
i tried it your way, but if you just shell without the returnvalue= you get
an error, take off the paren and it all works beautifully
Shell "C:\WINDOWS\system32\mspaint.exe", 1

that is the only line you need in the whole thing.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Gary''s Student" wrote:

I am having trouble getting Paint started:

Sub paint1()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
AppActivate ReturnValue
End Sub

Raises a run time error 5

Sub paint2()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
MsgBox (ReturnValue)
AppActivate ReturnValue
End Sub

Works just fine. Why do I need the MsgBox() before the AppActivate??

--
Gary''s Student - gsnu200755

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Shell Problem

Gary's Student,

I'm guessing that your goal is to save a picture of a range in some picture
format like gif. If that's the case, it might be more efficient to create a
chart on the active sheet with nothing in it, paste what you placed using
the range's copypicture method into the chart, export the chart as a gif to
wherever you want it and then delete the chart.

Steve


"Gary''s Student" wrote in message
...
First, thank you very much for you help. I do appreciate your interest &
willingness to help.

Here is a sample of what is happening:

Sub pai()
Dim ReturnValue, i As Integer
For i = 1 To 4
Cells(1, i).Value = i
Next
Range("A1:D1").CopyPicture Appearance:=xlScreen, Format:=xlPicture
Shell "C:\WINDOWS\system32\mspaint.exe", 1
SendKeys "^v", True
End Sub

1. the cells are filled
2. the picture is copied
3. Paint is activated
4. CNTRL-v is issued

Sadly the CNTRL-v is accepted by Excel rather than Paint.
--
Gary''s Student - gsnu200755


"John Bundy" wrote:

I see where you get those examples in the help but they are wrong, they
error
if you run them (as you know), just give the program focus with the ,1 at
the
end of the shell script
--
-John
Please rate when your question is answered to help us and others know
what
is helpful.


"Gary''s Student" wrote:

Thanks for your response. Its the AppActivate that is failing. It
need it
to make Paint the active application. If I omit the AppActivate, any
subsequent commands I send end up going to Excel rather than Paint.

I need them to go to Paint


b.t.w. I don't have this problem running Word from Excel.
--
Gary''s Student - gsnu200755


"John Bundy" wrote:

I've never totally understood the why's, and the first time i worked
with it
i tried it your way, but if you just shell without the returnvalue=
you get
an error, take off the paren and it all works beautifully
Shell "C:\WINDOWS\system32\mspaint.exe", 1

that is the only line you need in the whole thing.
--
-John
Please rate when your question is answered to help us and others know
what
is helpful.


"Gary''s Student" wrote:

I am having trouble getting Paint started:

Sub paint1()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
AppActivate ReturnValue
End Sub

Raises a run time error 5

Sub paint2()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
MsgBox (ReturnValue)
AppActivate ReturnValue
End Sub

Works just fine. Why do I need the MsgBox() before the
AppActivate??

--
Gary''s Student - gsnu200755



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Shell Problem

Why use AppActivate

Sub paint1()
Dim ReturnValue
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Gary''s Student" wrote in message
...
I am having trouble getting Paint started:

Sub paint1()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
AppActivate ReturnValue
End Sub

Raises a run time error 5

Sub paint2()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
MsgBox (ReturnValue)
AppActivate ReturnValue
End Sub

Works just fine. Why do I need the MsgBox() before the AppActivate??

--
Gary''s Student - gsnu200755



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Shell Problem

I use AppActivate to make Paint the active window. Without it my SendKeys
end up going to Excel instead of Paint. For example:

Sub paintum()
Dim ReturnValue, i As Integer
Range("A1:D1").CopyPicture Appearance:=xlScreen, Format:=xlPicture
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)

MsgBox (ReturnValue)

AppActivate ReturnValue
SendKeys "^v", True

End Sub

Works just fine...The picture is copied to Paint...After I acknowledge the
MsgBox.
If I omit the MsgBox, the Macro fails
If I omit both the MsgBox and the AppActivate, the macro pastes the picture
back onto the spreadsheeet!!

I would rather not have to acknowledge a MsgBox just to get paste to work.

--
Gary''s Student - gsnu200755


"Bob Phillips" wrote:

Why use AppActivate

Sub paint1()
Dim ReturnValue
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Gary''s Student" wrote in message
...
I am having trouble getting Paint started:

Sub paint1()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
AppActivate ReturnValue
End Sub

Raises a run time error 5

Sub paint2()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
MsgBox (ReturnValue)
AppActivate ReturnValue
End Sub

Works just fine. Why do I need the MsgBox() before the AppActivate??

--
Gary''s Student - gsnu200755




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Shell Problem

Personally, i think the code runs too fast for the shell to work, if you run
this
Dim ReturnValue, i As Integer
Range("A1:D1").CopyPicture Appearance:=xlScreen, Format:=xlPicture

Shell "C:\WINDOWS\system32\mspaint.exe", 1

Application.SendKeys " ", True
Application.SendKeys "^v", True

from code, the space will be place in your code where your cursor is. If you
attach this to a button it works perfectly, take out the sendkeys " " and it
is again too fast.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Gary''s Student" wrote:

I use AppActivate to make Paint the active window. Without it my SendKeys
end up going to Excel instead of Paint. For example:

Sub paintum()
Dim ReturnValue, i As Integer
Range("A1:D1").CopyPicture Appearance:=xlScreen, Format:=xlPicture
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)

MsgBox (ReturnValue)

AppActivate ReturnValue
SendKeys "^v", True

End Sub

Works just fine...The picture is copied to Paint...After I acknowledge the
MsgBox.
If I omit the MsgBox, the Macro fails
If I omit both the MsgBox and the AppActivate, the macro pastes the picture
back onto the spreadsheeet!!

I would rather not have to acknowledge a MsgBox just to get paste to work.

--
Gary''s Student - gsnu200755


"Bob Phillips" wrote:

Why use AppActivate

Sub paint1()
Dim ReturnValue
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Gary''s Student" wrote in message
...
I am having trouble getting Paint started:

Sub paint1()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
AppActivate ReturnValue
End Sub

Raises a run time error 5

Sub paint2()
Dim ReturnValue, i
ReturnValue = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
MsgBox (ReturnValue)
AppActivate ReturnValue
End Sub

Works just fine. Why do I need the MsgBox() before the AppActivate??

--
Gary''s Student - gsnu200755






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
Shell function problem (MS Access) mabond Excel Programming 6 June 8th 07 11:35 AM
Problem with Shell command Andrew Hall NZ Excel Programming 14 December 21st 06 06:27 PM
Shell Problem Stuart[_29_] Excel Programming 1 December 10th 05 12:00 PM
Shell Stuart[_20_] Excel Programming 1 February 17th 05 01:50 AM
Problem using Excel's "Shell" command Jim Simpson Excel Programming 0 May 20th 04 06:28 PM


All times are GMT +1. The time now is 11:02 PM.

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

About Us

"It's about Microsoft Excel"