Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a task to open pdf documents after selecting Files in selection lists and button click. But the real hassle is they are on different server. Any ideas how to crack this?
I did a similar thing using Excel documents. I accomplished this by:
Sub LaunchFile()
'Launch the file
set val=ActiveDocument.Fields("Filename").GetPossibleValues
'make sure not opening too many documents
x = vbOK
if val.count > 5 then
x=msgbox("Opening many documents can take a long time. Do you wish to open " & val.Count-1 & " documents?", vbOkCancel, "Confirm open")
end if
'if ok to launch
if x = vbOk then
for i=0 to val.Count-1
run val.Item(i).Text
next
end if
End Sub
Sub Run(ByVal sFile)
Dim shell
Set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & sFile & Chr(34), 1, false
Set shell = Nothing
End Sub
You should be able to filter for a few files, and then click the button to launch them. The system will launch the PDF file with the application that is associated with PDF files. I hope this helps!
Thank you. will try that. does this work to open files in different server?
Yes. You just need to include the full path to the file. That's what I'm doing with my Excel files. Your path should look something like either of these:
\\server\share\folder\file.pdf
or
z:\folder\file.pdf