Variable in a Command Line String

taber13

Registered User.
Local time
Today, 17:25
Joined
Dec 12, 2000
Messages
11
I have some code that looks like this:

If stDocName Like "*" & ".pdf" Then RetVal = Shell("C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32 /p/h/n, C:\Configurator\Lit\tbd620.pdf", 0) Else GoTo 20

I would like to make C:\Configurator\Lit\tbd620.pdf a variable value but haven't had any luck.
 
ah, i see this is supposed to launch a hidden instance of acrobat which will print the given file. i knocked up a version of you're code as a function, which does launch acrobat in the way you want...

Function openPDF(strDocName As String) As Double
If strDocName Like "*.pdf" Then
'--fire the shell command to launch acrobat
'--note the use of chr(34) which is used to enclose the file paths in " " in the string we send to the
shell commands.
'--this prevents mis-interpretation of 'long filenames' by shell
'--as far as including the document filename as a variable is concerned, its just a case of string
concatenation
'--i also think the comma after the switches may have been a typo!

'-- i am using acrobat 3, which does not like the /n switch at all. i don't know if this really is a
valid switch in acrobat 4, may be worth confirming that.
openPDF = Shell(Chr(34) & "C:\Program Files\Acrobat 4.0\Reader\AcroRd32.exe" & Chr(34) & " /p/h " &
Chr(34) & strDocName & Chr(34), 0)
Else
'--not *.pdf file, do something else...
End If
End Function

_____________________________
it's then just a case of calling this function and passing the file you want as the argument (the function will return the 'handle' to the acrobat instance, which may or may not have a use for):-

RetVal = openPDF( "C:\YourDirectory\YourFile.pdf")


hope that helps.

axa

[This message has been edited by axa (edited 03-20-2001).]

[This message has been edited by axa (edited 03-20-2001).]
 
Store in in a string variable enclosed by quotes.

dim sLongFile
sLongfile = "C:\Configurator\Lit\tbd620.pdf"
 

Users who are viewing this thread

Back
Top Bottom