Opening Files of External Programs

Hi friends,

I am a new basic programmer..

I have 2 develop a program which stores files of diff. formats in some specific folder and then when prompted by user it should be opened in respective program.
Like :: *.doc in word, *.pdf in Acrobat and so on..

.........................
Plz help mw with logic and basic code outline 2..



Answer this question

Opening Files of External Programs

  • B. Travis Wright

    I'm terribly sorry.  *sigh*

    This forum is for .DotNet products. You could get better answers in a forum for COM based languages.

    VB6 also has a variety of ways of doing that, too. In VB6, I always liked the scripting library/File System Object (used a project reference windows/system32/scrrun.dll).

    As far as how get the correct utility to run in vb6, there is an API call for that and I wish I could remember it's name at the moment.

  • Hansjoerg

    Hi ReneeC,

    Its really nice thing 2 learn the updated things. Thanks for ur nice suggestion. Actually I think it will be much more helpful for me 2 learn VB.Net than VB.

    As per ur suggestion I will be also upgrading 2 VB.net but I am confussed abt its installation.. Would you please help me in its installation.. The components that I should have and the stuffs I should download for reading..

    Kabindra Bakey

  • Siva M

    Hi..

    Thanks for providing me link...

    But the thing is that I am unable 2 find the correct ans from there 2.. I searched many times but can't get..

    If possible plz post me the code..

    *************************
    Well it may be my fault that I can't find the right ans from the given link..



  • Richard Taylor

    I cannot use it in VB6.0.. I am not being able 2 find or get the system.process in my project..

    I started with new standard exe project.. Now I want to know is Which reference should I add in my project for making system.process...

    If i do not add any references and start writing system.process it says "Reference missing or object required."

  • Michael Luttmer

    Hi,

    I'm answering your questions based on this statement.

     Kebians wrote:

    Actually I think it will be much more helpful for me 2 learn VB.Net than VB.

    As per ur suggestion I will be also upgrading 2 VB.net but I am confussed abt its installation.. Would you please help me in its installation.. The components that I should have and the stuffs I should download for reading..

    Kabindra Bakey


    As stated many times, the focus of these forums is Visual Basic .NET. For VB6 questions, you should try posting at http://msdn.microsoft.com/newsgroups/.

    That's said, to do what you want to in VB6, add this into your Form / Class



    Private Declare Function ShellExecute Lib "shell32.dll" _
       Alias "ShellExecuteA" _
      (ByVal hwnd As Long, _
       ByVal lpOperation As String, _
       ByVal lpFile As String, _
       ByVal lpParameters As String, _
       ByVal lpDirectory As String, _
       ByVal nShowCmd As Long) As Long
    Const SW_SHOWDEFAULT As Long = 10

     


    And use this to open the file with its default application.


       Dim sFullPathToFile As String
       sFullPathToFile = "C:\temp\Test.doc"
       Call ShellExecute(0, "Open", sFullPathToFile, 0&, 0&, SW_SHOWDEFAULT)

     


    Remember to use the correct path.

    Best regards,

  • kabirbasha

    Thanks HUYN_MS,

    But I am confused abt the object process.start... I get error when use process.start



  • MJ Mullen

    Thanks for providing me link...

    But the thing is that I have searched that link 2 but I think I am such a fool that I am not being able 2 find the correct answer from the link

  • Mark Stega

    The links are to answer this question

    "As per ur suggestion I will be also upgrading 2 VB.net but I am confussed abt its installation.. Would you please help me in its installation.. The components that I should have and the stuffs I should download for reading.."

    I cannot help much with saving files in .doc or .pdf format if you want to do so.

    To launch a .doc or .pdf file using VB .NET (if the external program is installed on the machine of course), you can use
       Process.Start("<Path To File>")

    Hope this helps,


  • Ken Courts

    Thanks ReneeC,

    Although I didn't get my right ans I wanna thanks for ur reply and informing me abt this forum also..

    Since I am a beginer programmer I am terible surprised that VB6 is not related to Visual Basic General..

    So I would like 2 know some more basic abt it.. if possible u plz suggest me some good books or ebooks by which I can widen my knowledge.

    Beginer programer being Upset..Tongue Tied

  • newtWales

    Hi,

    You can download Visual Basic Express 2005 here http://msdn.microsoft.com/vstudio/express/vb/.

    To start learning Visual Basic 2005, you can go to http://msdn.microsoft.com/vbasic/default.aspx, and start with "Learn Visual Basic" links.

    Best regards,



  • Jimmy Code

    Hi Kebians,

    How fortunate you are to be learning in a vs2005 environment.

    What you want to do is a a simple file copy operation to begin with. There are lots of ways to achieve that.

    When you talk to .dot people, you'll hear a lot about classes. I think one of the best ways to learn about classes is to learn to use the object browser.
     
    Please see the fileinfo class. It has copy capabilities.

    Class Process and Class Startinfo will help you accomplich what you need to start these programs. If you do it right XP will keep track of the program that needs to run.

    This may sound like a daunting task but it not. It's more than ten lines of code... but not a whole lot more.

  • Shane Pilo

    Dear ReneeC,

    I am thankful for your reply...

    But A problem still exits that is.. I am programming in VB6.0 . So any more suggestions plz..

    ...................................


  • Melchior91598

    Hey!!!!

    I have a couple of really happy thoughts for you.

    1.) If you are a beginner why are you learning VB6 If I'm not mistaken, VB6 is old enough that it's no longer being supported by Microsoft If that isn't the case yet, it will be soon. So why learn an outdated language

    If it's because that's what you have... you can down load VB .Net Express right now and begin learning and be upto date in what you are learning with a language that is much more interesting and powerful.

    2.) If you take a look around the section where you download Express.... You'll find that Microsoft has written a book on Basic. It's not a book for beginners but it's really good and really clear.

    I think the most powerful way to learn is to pick a small project and start writing and come back here with your questions.

    The VB Expresses are Betas and will expire in May. But in Early Nov the VS2005 product will be out and if I'm not mistaken, VB Express is supposed to sell for about $50. I'll be honest, I'm an experienced programmer and I've been programming in VB6 for a lot of years now and when I saw the Express Beta's i was so impressed that I just dropped VB6 instantly and began programming in Dot Net.

    Soooooooo, I think everything you want is right here. :)

  • wilrodmo

    It would be easier to help you if you let us know what the error was.

    Here's the article on Process.Start. http://msdn2.microsoft.com/en-us/library/53ezey2s.

    Best regards,

  • Opening Files of External Programs