dos command

peioz

Board Regular
Joined
Jul 17, 2002
Messages
78
I have the following batch file :

c:\gs\gs8.13\bin\gswin32c -dBATCH -dNOPAUSE -sDEVICE=pnggray -r300 -sOutputFile=Z:\100R\preview\cl-tech-0010-01.pdf z:\100R\cl-tech-0010-01.pdf

I tried to put this batch into VBA with the Shell command. But I can't get it to work. It seems like the VBA doesn't pass all the switches to dos.
It looks like this.

Shell ("c:\gs\gs8.13\bin\gswin32c -dbatch -dnopause -sdevice=pnggray -r72 -soutputfile=c:\test.pdf Z:\100R\CL-TECH-0010-01.pdf")

I can use the Batch file, but it would be nice to put it all in VBA.....

Is there an easy way to accomplish this ?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I note that sometimes Excel struggles if we give it too much to do in a single line. Try defining your batch command as a separate string and use that in the Shell argument. You may need to explicitly open the adobe .exe file.

Here is a basic working example :-

Code:
Sub open_file()
    Notepad = "C:\WINNT\Notepad.exe"
    FileDir = "C:\temp\"
    FileName = "test.txt"
    '------------------------------
    RunString = Notepad & " " & FileDir & FileName
    retval = Shell(RunString, vbNormalFocus)
End Sub
 
Upvote 0
is there a way to run dos command like "net send" or "shutdown" by having excel look for the command as a result of formulea? this would be very helpfull to me
 
Upvote 0

Forum statistics

Threads
1,215,693
Messages
6,126,248
Members
449,304
Latest member
hagia_sofia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top