79118237

Date: 2024-10-23 13:59:20
Score: 0.5
Natty:
Report link

Re double-quoting.... I have a function Q(...) which simply encloses the provided string in double-quotes - assumption being that the string itself doesn't contain one.

e.g. AppPath = Q("C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe")

You need the double quotes because the provided string is a literal. If you provide a variable instead, it's easy to see where they go...

str = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"

AppPath = Q(str)

...but of course you don't need to do this.

However, I would go with

AppPath = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"

SrcPath = Environ("UserProfile") & "\Downloads\20200509_Order_of_08_05_2020.PDF"

shellCommand = Q(AppPath) & " " & Q(SrcPath)

Function Q(str as String) as String
   ' Avoid quoting a quoted string
   If Left(Trim(str),1) = Chr(34) then
       Q = str
   else
       Q = Chr(34) & str & Chr(34)
   endif
End Function
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Stuart