Results 1 to 8 of 8

Thread: Associate File Extension with a program and opening a file

  1. #1

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Talking

    I have made a program that reads and writes to db's which has the extension ".mdb". Now i tried the code if i changed the extension to ".kom" instead and it still works fine and dandy but they can't open it in msacess unless they say open with ms access. Now i was wondering if there is a way in code to say that ".kom" files have "c:\myico.ico" as an icon and open with "c:\myprog.exe"? I know how to do it manually but have no idea how to do it in code.

    Also this is how you can open a file with its default extension.
    Code:
    Call ShellExecute(Me.hwnd, vbNullString, "C:\happy.txt", vbNullString, vbNullString, 0&)
    and here is another way
    Code:
    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
    Private Const SW_HIDE = 0
    Private Const SW_MAXIMIZE = 3
    Private Const SW_MINIMIZE = 6
    Private Const SW_NORMAL = 1
    
    
    Call ShellExecute(Me.hwnd, vbNullString, "C:\happy.txt", vbNullString, vbNullString, SW_NORMAL)
    Now is there a way to specifiy what program you want the file to be opened it? Like for example instead of having
    "C:\mytext.txt" open in notepad maybe i want it to open up in wordpad or ms word. Is there a way to do this?

    Thanks!!

    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  2. #2
    Guest
    If you want to open a file strictly with msaccess use the standard Shell() method.
    Code:
    Shell "msaccess mydb.mdb", 1

  3. #3

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408
    I am guessing the my.mdb would have to be the path of the file so i put

    Code:
    Shell "msaccess c:\mydb.mdb", 1
    i tried it without the c:\ and i still got the same error. file not found. Any siggestions? The reason I have to say open up in access is cause i want it to open

    Code:
    Shell "msaccess C:\Vocab Info.kom", 1
    that in msacess. Thanks
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  4. #4

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408
    Alright I am stupids. I got what you meant. You mean this:
    Code:
    Shell "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE C:\Vocab Info.mdb", 1
    Well it works to a degree. When I click the command button it says:

    The command line you used to start Microsoft Access contains an option that Microsoft Access doesn't recongnize.

    Exit and restart Microsoft Access using valid command-line options.

    then when i hit ok ms access comes up and then says:

    Msacess can't find the database file 'C:\Vocab.mdb.'

    Make sire you entered the correct path and file name.

    why the heck does it say Vocab.mdb and not what i entered, which is Vocab Info.mdb? Thanks

    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  5. #5

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Unhappy

    Doesn't anybody know how to make it so that .kom file extension will automatically open up with my program and have a certain icon? Somebody must know. PLease help me!! Oh and it must be in code not manually done because I know how to do it manually. Thanks!!
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  6. #6
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    Try this:

    Code:
    ------------------------------------------------------------
    strAccess = ¡°C:\Program Files\Microsoft Office\Office\Msaccess.exe ¡±
    ¡®Myfile.mon is an Access file whose extension has been modified
    strFileToOpen = ¡°C:\My Documents\Myfile.mon¡±

    Shell strAccess & Chr$(34) & strFileToOpen & Chr$(34), vbMaximizedFocus
    ------------------------------------------------------------
    Visual Basic Professional 6.0

  7. #7
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    http://forums.vb-world.net/showthrea...threadid=33351

    There you can see how to attempt the Registry.

  8. #8

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