Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

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

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
0
fzkt6p
Asked:
fzkt6p
1 Solution
 
DhaestCommented:
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 ?
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q170/9/18.asp&NoWebContent=1
2. Start an executable
"Using the ShellExecute Function to Launch Applications in Visual Basic"
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvb4/html/msdn_shelexec.asp
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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthregwrite.asp

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
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now