Calling a Command Prompt to execute user defined actions

musoguy

Board Regular
Joined
May 20, 2008
Messages
173
I am trying to open a PDF file in a certain way through VBA by calling a command prompt. I have each individual part working, but can't put them together!

I can call the command prompt:

Code:
Call Shell("cmd.exe " & dosCmd, vbNormalFocus)
I also know the two commands I want to go in the prompt (I'd love to turn this into one command instead of two but I'm not sure how to do it, or if it is even possible plus I presume that is a question for a different forum!):

Code:
cd c:\program files\adobe\acrobat 9.0
start acrobat.exe /A "page=10=Open Actions" "M:\My Books\allegro.pdf
The DOS command opens a particular PDF (allegro) on page 10.

I cannot figure out the code however to get VBA to put the commands in the command prompt, execute them and then close the command prompt window.

To complicate things further, the PDF document and page number needs to change dependent on the values in and around the active cell when I run the macro. For example if the value in the active cell (A4) is Whistle Down The Wind. Cell B4 has the value The Vault's Of Heaven. Cell C4 has the hidden value of 5 (which is the page number for The Vaults Of Heaven). In this example the commands to go into the command prompt would be:

Code:
cd c:\program files\adobe\acrobat 9.0
start acrobat.exe /A "page=5=Open Actions" "M:\My Books\Whistle Down The Wind.pdf
So in other words I need parts of the command prompt command to be defined by the active cell when the macro is run.

Is any of this even possible?! My head is swimming just thinking about it, which I need to stop doing before I go crazy! I hope someone has a clue what I am talking about and if even a small part of it is possible!

James
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
A stupid method (perhaps), but one that will likely work is to add some wait statements, and use SendKeys to 'type' what you want into the shell and execute.
 
Upvote 0
Thanks for the reply Sal. Please forgive me, I am pretty new to all this. If you have a moment would you mind giving me a really short example of this to get me on my way.

James
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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