'Text2.Text = "C:\MyPath\MyDocument.pdf"
'Shell "C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe" & " " & Text2.Text, vbNormalFocus
this code correctly work for one user pc, but other users that use the system cant be open the file , how i can make the file published??
Are you getting fault codes or messages?
Are all users on the same Windows version (this could change location of AcroRd32 ?
Are all users using the Adobe Reader 10.0 ?
Is your target PDf in the same path for all users?
there may be two reasons mostly :
1.there may not be
Adobe Reader installed in the target system or they are using different version.
2.path may be different and i hope that you entered the correct path
so its make sure that above 2 resons are there in your application
if still having some problems then post your problem and also post what error you are getting, but before posting make sure that you have done through above 2 reasons.
okay , the previous code work and open the file from the user that upload the file , but when other user try to open it its give an error during opening the file because the file can't be found but the adobe reader open.
because the file can't be found but the adobe reader open.
so do you want that whenever the file is not found then adobe reader should not open ?
So as rishif2 says (he types faster than I do) it sounds like the file you want to open is in a different folder? Or does not exist on that computer? Or other?
Or there is some other problem like a variation in the file name?
The answer may be simply allowing for seperate locations
You can protect yourself by checking for the file before you try to open it:
'Check to see if file is where it is supposed to be If dir("C:\MyPath\MyFile.PDF") ="" then 'Look someplace else or other action. Else 'use the code you used before End if
As an alternative:
Would it be okay to have the user search for the file?
If so one solution would be to use the common dialog box.
To use the Common Dialog Box
Click on Project, Components, Check the box next to Microsoft Common Dialog Control x.x
Find the control in the tool box and click on it
Draw it on your form as you would any other control.
It will not show in runtime
On the Property Sheet change Name to CDL1
'Check to see if file is where it is supposed to be If dir("C:\MyPath\MyFile.PDF") ="" then 'If the path or file is broken then msgbox "Please Select File to Open" CDL1.Filter = "All Files (*.*)|*.*|PDF Files (*.pdf)|*.pdf|" CDL1.InitDir = ("C:\MyPath") 'Same directory/file folder as above CDL1.ShowOpen 'At this point the dialog box opens in the 'directory where the file was supposed to be. If CDL1.FileName = "" Then 'The open was canceled msgbox "Contact Administrator For Assistance" Exit Sub End If ' CDL1.FileName blank Else 'open the file with same code as before End if ' dir(C: . . .
If you need something different then check back
this code should i put inside the Command and include with it the previuos code , i do that but nothing happend with no error msg
Apologies:I thought I had tested this. The following works for me, if you get all
of the paths right.
The second If/Then should have an Else that opens the file that has been found.
Also a better Filter value.
Code covers 4 possibilities: File in expected place; Show Open Window if file is not located where or named as expected; User closes Open Window; User Selects a file from the open window.
All 4 work for me with this code.
Private Sub Command1_Click() 'Check to see if file is where it is supposed to be ' Text1.Text has the expected path (or hard code in place of Text1) If Dir(Text1.Text) = "" Then 'If the path or file is broken then The Dir Returns "" MsgBox "Please Select File to Open" ' Cleaned up the filter some so that it only shows PDF files CDL1.Filter = "PDF Files *.pdf|*.pdf" ' Text3 (or hard code the path) ' Just the folder that the PDF should be in, or ' alternate known location for the file. CDL1.InitDir = (Text3.Text) 'Same directory/file folder as above CDL1.ShowOpen 'At this point the dialog box opens in the ' If the user closes the File Open Window then they get a message to call for help ' The else opens the file If CDL1.FileName = "" Then 'The open was canceled MsgBox "Open operation was cancelled" Exit Sub Else Shell "C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe" & " " & Text1.Text, vbNormalFocus End If ' CDL1.FileName blank Else ' The file was found where expected so open it Shell "C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe" & " " & Text1.Text, vbNormalFocus End If ' dir(C: . . . End Sub
Let me know if that works for you.
Edited by Klahr_R
as I'm looking into the MVC pattern, I thought I'd create a small application to understand a bit more.
Let's look at the code:
//model package model; public ...
so I can have in first column -00.000146400000 ...
I have an assignment to output contents from a .txt file to html. I'm able to output the information from the .txt to the console but how would I output ...