Results 1 to 19 of 19

Thread: [RESOLVED] PDF Files in VB Project

  1. #1

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    97

    Resolved [RESOLVED] PDF Files in VB Project

    Good Day,
    I am having a problem with the following: -

    Name:  VS Form.jpg
Views: 154
Size:  33.8 KB

    On the Top of the form, I have 2 buttons "Help" and "License Agreement". These files is in a PDF format as well as in a word format. If one clicks on the button, it opens automatically with the following codes

    Private Sub btnEULA_Click(sender As Object, e As EventArgs) Handles btnEULA.Click
    System.Diagnostics.Process.Start("C:\Program Files\EULA1.pdf")
    End Sub

    Private Sub btnHelp_Click(sender As Object, e As EventArgs) Handles btnHelp.Click
    System.Diagnostics.Process.Start("C:\Program Files\Symbolic Signs Help File.pdf")
    End Sub

    Unfortunately some users do not understand to copy these 2 files in the correct Folder for these buttons to work and I am looking how to code it to automatically include these files to work with the buttons when the software is installed.

    I wanted to include them in the Application Files when publishing the setup file, but it appears that one cannot include PDF nor Word Files.

    Is there a way I can do this Programmatically?

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,773

    Re: PDF Files in VB Project

    Quote Originally Posted by kobusjhg View Post
    Unfortunately some users do not understand to copy these 2 files in the correct Folder for these buttons to work and I am looking how to code it to automatically include these files to work with the buttons when the software is installed.
    You seem to understand the downside of how you currently have this coded, but just to underscore the point, it is a horrible coding and deployment strategy for your application to only work properly if the end user needs to manually copy files anywhere, let alone the root of the Program Files folder, which an end user wouldn't even have permissions to do if your company is doing security properly.

  3. #3

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    97

    Re: PDF Files in VB Project

    Quote Originally Posted by OptionBase1 View Post
    You seem to understand the downside of how you currently have this coded, but just to underscore the point, it is a horrible coding and deployment strategy for your application to only work properly if the end user needs to manually copy files anywhere, let alone the root of the Program Files folder, which an end user wouldn't even have permissions to do if your company is doing security properly.
    I do agree with you completely. This is one of the reasons I would like it to be changed, and as I have stated I have tried various options to do that.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,810

    Re: PDF Files in VB Project

    You can add them to the project, set the Build Action to Content and set Copy To Output Directory to Copy If Newer or Copy Always. They will then be copied to your output folder automatically when you build and can be included in your installer, probably automatically as well. You can then use Application.StartupPath in code to get the folder path.

  5. #5

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    97

    Re: PDF Files in VB Project

    Quote Originally Posted by jmcilhinney View Post
    You can add them to the project, set the Build Action to Content and set Copy To Output Directory to Copy If Newer or Copy Always. They will then be copied to your output folder automatically when you build and can be included in your installer, probably automatically as well. You can then use Application.StartupPath in code to get the folder path.
    Thank You jmcilhinney, I am going to try that and reply back to you. I have tried to add it to the project Via the "Add Item" mode, but as I have said it did not work. I will do it this way. Thank You.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,810

    Re: PDF Files in VB Project

    If the files already exist then you should use Add Existing Item and then browse to the file.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,810

    Re: PDF Files in VB Project

    I have moved this thread to the Application Deployment forum because that's really what the issue is about, rather than actual VB.NET. You should also explain exactly how you are creating the installer. Are you using ClickOnce, i.e. the publishing functionality built into the project, or creating a Setup project or something else?

  8. #8

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    97

    Re: PDF Files in VB Project

    Quote Originally Posted by jmcilhinney View Post
    I have moved this thread to the Application Deployment forum because that's really what the issue is about, rather than actual VB.NET. You should also explain exactly how you are creating the installer. Are you using ClickOnce, i.e. the publishing functionality built into the project, or creating a Setup project or something else?
    I am using on the top menu
    Project
    Program properties
    Publish

    If I want to add the files
    I go to Solution Explorer
    Right Click My Project
    Add Existing Item
    I add the 2 files after I was asked to replace them and I replace them

    I deleted the Button Code I have written. before
    I go to Publish Wizard
    I have selected a folder "Publish" where my Installation File will be Saved in
    I install the program, it installs, but still does not open the files.
    This is where I am Stuck now.

  9. #9
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,773

    Re: PDF Files in VB Project

    Quote Originally Posted by kobusjhg View Post
    I deleted the Button Code I have written. before
    I go to Publish Wizard
    I have selected a folder "Publish" where my Installation File will be Saved in
    I install the program, it installs, but still does not open the files.
    This is where I am Stuck now.
    After installation, have you used Windows Explorer to browse to the folder that the program is installed to and verified that these documents are now present there as well?

    You say you deleted the Button Code that you had. Did you replace that code with new code? Or do you just not have any code at all for those two buttons? If the latter, then your problem is you are expecting magic to happen.

  10. #10

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    97

    Re: PDF Files in VB Project

    Quote Originally Posted by OptionBase1 View Post
    After installation, have you used Windows Explorer to browse to the folder that the program is installed to and verified that these documents are now present there as well?

    You say you deleted the Button Code that you had. Did you replace that code with new code? Or do you just not have any code at all for those two buttons? If the latter, then your problem is you are expecting magic to happen.
    Nope, Seems I expected magic to happen.
    Thanx, Let me go back and re-do

  11. #11

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    97

    Re: PDF Files in VB Project

    Quote Originally Posted by OptionBase1 View Post
    After installation, have you used Windows Explorer to browse to the folder that the program is installed to and verified that these documents are now present there as well?

    You say you deleted the Button Code that you had. Did you replace that code with new code? Or do you just not have any code at all for those two buttons? If the latter, then your problem is you are expecting magic to happen.
    I put the code back, the 2 files is in the folder. It does not work when I execute the program.

  12. #12
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,773

    Re: PDF Files in VB Project

    Quote Originally Posted by kobusjhg View Post
    I put the code back, the 2 files is in the folder. It does not work when I execute the program.
    That's a shame.

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,810

    Re: PDF Files in VB Project

    It's frustrating when people insist on being lazy explaining their problem because then we have waste our time and yours dragging the information out of you. Telling us "it doesn't work" it's all but useless when you don't show us what "it" is or tell us what it actually does. Show us the code and explain what actually happens. For a start, did you do what I instructed and use Application.StartupPath for the folder?

  14. #14
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,322

    Re: PDF Files in VB Project

    So you put the code back so that it looks like this again?
    Code:
    System.Diagnostics.Process.Start("C:\Program Files\EULA1.pdf")
    sigh... if so, that's why it doesn't work... the pdf files are not at that location ... where are they? they're with the application ... fortunately there is a method to get the application.path ...


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  15. #15

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    97

    Re: PDF Files in VB Project

    Quote Originally Posted by jmcilhinney View Post
    You can add them to the project, set the Build Action to Content and set Copy To Output Directory to Copy If Newer or Copy Always. They will then be copied to your output folder automatically when you build and can be included in your installer, probably automatically as well. You can then use Application.StartupPath in code to get the folder path.
    I do not find the Content option in VB. I came across it in C# once.

    I do my Installation File as follow: -
    Project
    Add Item
    New

    Sorry jmcilhinney,
    I found it on the right hand side.
    how bloody stupid of me.

    I will do it and see if it works.

    I deleted my Button code and it works perfectly.
    Last edited by kobusjhg; Sep 14th, 2023 at 01:55 PM.

  16. #16
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,773

    Re: [RESOLVED] PDF Files in VB Project


  17. #17

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    97

    Re: PDF Files in VB Project

    Quote Originally Posted by jmcilhinney View Post
    It's frustrating when people insist on being lazy explaining their problem because then we have waste our time and yours dragging the information out of you. Telling us "it doesn't work" it's all but useless when you don't show us what "it" is or tell us what it actually does. Show us the code and explain what actually happens. For a start, did you do what I instructed and use Application.StartupPath for the folder?
    Thanx Again jmcilhinney,

    It is working. I am sorry for being frustrating and wasting everybody's time, but I think it is trying to explain College Maths to a 11 yr old. At last with all your help jmcilhinney, OptionBase1, techgnome I got it right by opening my eyes and look for the right stuff as explained by you all.

  18. #18
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,810

    Re: [RESOLVED] PDF Files in VB Project

    It's not the end of the world if we get frustrated but, if we get too frustrated, we may decide to not help any more and that would be bad for you. Whenever you post here or in a similar site, ALWAYS stop and think about what information is relevant to the issue. Whether it's the first post in a thread or not, ALWAYS answer the questions "what am I trying to achieve", "how am I trying to achieve it" and "what happens when I try". The last5 one is important because different behaviour is indicative of different issues, so we have an idea of what we're looking for.

  19. #19

    Thread Starter
    Lively Member kobusjhg's Avatar
    Join Date
    Jul 2023
    Location
    Pretoria, South Africa
    Posts
    97

    Re: [RESOLVED] PDF Files in VB Project

    Quote Originally Posted by jmcilhinney View Post
    It's not the end of the world if we get frustrated but, if we get too frustrated, we may decide to not help any more and that would be bad for you. Whenever you post here or in a similar site, ALWAYS stop and think about what information is relevant to the issue. Whether it's the first post in a thread or not, ALWAYS answer the questions "what am I trying to achieve", "how am I trying to achieve it" and "what happens when I try". The last5 one is important because different behaviour is indicative of different issues, so we have an idea of what we're looking for.
    Agreed, I will try my best to improve.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width