Small VB Question (1% brainpower required)
Results 1 to 10 of 10

Thread: Small VB Question (1% brainpower required)

  1. #1
    Senior Member
    Join Date
    May 2002
    Posts
    168

    Arrow Small VB Question (1% brainpower required)

    Hey everyone, I know you may think AO is turning into a VB help board, with all the VB stuff going on at the minute, but beleive me I have looked in numerous places for the answer to this simple question, but still could not find the answer... Please spare a moment of you precious time to read it...

    Question:

    I know that this code is able to open an .exe on your computer...

    Shell "C:\whever the .exe file is"

    I would like to know is there a string of code like this one where you can for instance open an html file of a word document on the computer?

    Thanks to anyone whose thinking about helping

    -Prankster
    \"Why is the bomb always gettin\' the last word?\" - Will Smith - Lost & Found (2005)

  2. #2
    Junior Member
    Join Date
    Jul 2002
    Posts
    6
    Not sure, you have tried "filename" "application/path", sry I'm not a prog but I have seen this somewhere.
    http://sw33t.no.sapo.pt/pic/mask1.gif
    Seek balance and you will find peace.

  3. #3
    Junior Member
    Join Date
    Jun 2002
    Posts
    11
    http://www.vbcode.com/asp/showsn.asp?theID=29 might help for html pages.




    p3pC

  4. #4
    Senior Member
    Join Date
    May 2002
    Posts
    168
    thanks guys:

    p3pC: I'll have a go and let you know how I get on, thanks

    Prankster

    OK, this is what happened :

    I added the top part of the code (declarations), into General Declarations.
    The I created a button and put the "Code" part in between Private Sub Command1_Click() and End Sub.

    I ran the program and got a "Compile Error" and the "Const" part of this line in the General Declarations was highlighted...

    Public Const conSwNormal = 1

    Thanks a lot for the help
    \"Why is the bomb always gettin\' the last word?\" - Will Smith - Lost & Found (2005)

  5. #5
    Senior Member
    Join Date
    Oct 2001
    Location
    Helsinki, Finland
    Posts
    570

    Re: Small VB Question (1% brainpower required)

    Originally posted here by Prankster
    I would like to know is there a string of code like this one where you can for instance open an html file of a word document on the computer?
    What do you mean by this? If you want to open an html document in Word couldn't you just run Word with the shell command and add the html file name as a parameter?
    Code:
    Shell "c:\something\word.exe x:\some\where\doc2open.html"
    Edit/Add: Checked that page p3pC suggested, you want to open a www-page with a piece of vb-code? Right now I'm on a comp which doesn't have VB installed so I can't try these but what if you separate "Public Const conSwNormal = 1" to two different lines, line break after the word 'Const'? I can't see that original layout matching any syntax I know but I might be wrong.

    Edit/Add2: http://www.thebestweb.com/VBFAQS/faq_winAPI.asp has an example code for opening a www-page, too. Check if that works better than the first one.

    Edit/Add3: Wheee, always new cool VB sites... Check this out: http://www.kather.net/VisualBasicSource/scindex.htm
    Q: Why do computer scientists confuse Christmas and Halloween?
    A: Because Oct 31 = Dec 25

  6. #6
    Junior Member
    Join Date
    Aug 2002
    Posts
    17

    Might help

    There is an alternative to the SHELL command in VB, called ShellExecute (API).

    You get more detailed info about it here:
    http://www.imt.net/~joe/matt/program...ellExecuteAPI/

    It's more powerful than VB's built-in function so I would recommend to use this one.

    But I agree with ZeroOne: You've gotta know the correct executable for the app and then just pass the document as a parameter.
    You can find associated executables to specific file-formats using the FindExecutable and GetAssociatedExecutable APIs.
    They are described and declared as explained on this page:
    http://216.26.168.92/files/tip522.html

    I hope this helped a bit.



    Sledge
    This post has been [shadow]sledged[/shadow]

  7. #7
    Senior Member
    Join Date
    Oct 2001
    Location
    Helsinki, Finland
    Posts
    570
    Erhm... "/progra...hellExecuteAPI/"... Hell Execute....

    Sledge, my Edit/Add2 points to an API related link but it's good you explained it (with new links) because I didn't do it at all.
    Q: Why do computer scientists confuse Christmas and Halloween?
    A: Because Oct 31 = Dec 25

  8. #8
    Senior Member
    Join Date
    May 2002
    Posts
    168
    Thanks Guys, I got the paramaters working... it's great.
    Thanks Again
    -Prankster
    \"Why is the bomb always gettin\' the last word?\" - Will Smith - Lost & Found (2005)

  9. #9
    Antionline Herpetologist
    Join Date
    Aug 2001
    Posts
    1,165
    A simple solution would be Shell "start c:\path of the file". That would open the file with whatever program it is associated with. i.e. a HTML file with IE or a .doc file with Word etc...
    Cheers,
    cgkanchi
    Buy the Snakes of India book, support research and education (sorry the website has been discontinued)
    My blog: http://biology000.blogspot.com

  10. #10
    Senior Member
    Join Date
    May 2002
    Posts
    168
    hey, thanks a lot, that helps a lot because say if I wanted to use IE to open a html doc. I would put

    Shell "C:\blablabla\iexplore.exe www.whatever.com"

    But I just realised, not everyone will use IE, and they may not have it installed in the same place as me, they might not even have it at all.

    Thankyou very much
    \"Why is the bomb always gettin\' the last word?\" - Will Smith - Lost & Found (2005)

Posting Permissions

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