• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Open PDF

rolo

Member
Hello,

I used this code to open a PDF file:
Code:
MyPDF="C:\abc.pdf"
ActiveWorkbook.FollowHyperlink MyPDF

It worked fine, except that it showed an annoying warning message before opening the PDF (even I had application.displayalerts=false)

Today I have found this great code that opens a PDF file without warning message:
Code:
Shell "CMD /C START """" ""D:\mypdfs\myfile2.pdf""", vbHide

My question: How can I add a variable pdf name inside this code?

Thanks!
 
Code:
Sub Main()
  Dim fn$, s$
  fn = "C:\Users\lenovo1\Dropbox (Personal)\_Excel\pdf\_1.pdf"
  If Dir(fn) <> "" Then Shell "cmd /c " & """" & fn & """", vbNormal
End Sub[code]
 
  • Like
Reactions: Hui
Hi Kenneth, works perfect, thanks!

Just a question:

Why you declare fn$ variable but on the rest of the code you only use fn without $ sign?

;)
 
Back
Top