What is the code in Visual Basic 6 to Open a Word Document on a server without Word installed?

Posted on 2005-04-11
Last Modified: 2011-09-20
I am using VB 6 and coding an app requiring a Word document to be opened upon Button click.  In addition, I need to know how to have the following occur upon seperate button clicks:
1.  Start an executable
2.  Change a registry key
3.  Write to a log file
Question by:fzkt6p
    1 Comment
    LVL 53

    Accepted Solution

    REMINDER: Normally you only ask 1 question (or 2 if they are related), but not 4 different questions at the same time !!!

    1. To open a Word-document without word installed -> it will be openend in another program then ?
    2. Start an executable
    "Using the ShellExecute Function to Launch Applications in Visual Basic"
    3. Registry:
    If you include a reference to Windows Scripting in your project, you can write to the registry with just a couple of lines of code.

    dim wshShell
    Set wshShell = CreateObject("WScript.Shell")
    strTemp = WshShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\")

    WshShell.RegWrite ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader", "Goocher!", "REG_SZ");

    Full docs are at

    4. write to a file
            If strFilename = "" Then strFilename = App.Path & "\hist.txt"
            fh = FreeFile
            Open strFilename For Append As fh
            Print #fh, Format(Now, "dd/mm/yyyy hh:nn:ss") & " - " & Environ("username") & " - " & strProcedure
            Close fh

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now