?
Solved

Opening a word document in word from VB

Posted on 2003-03-27
3
Medium Priority
?
155 Views
Last Modified: 2010-05-01
Hi, i have a prob. I need to know how to open MSWord, and open a certain doc inside Word.
0
Comment
Question by:beauvoir2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Accepted Solution

by:
aelatik earned 100 total points
ID: 8220403
You already asked this question...

Dim OpenWorkFile
Set OpenWorkFile = CreateObject("WORD.APPLICATION")
OpenWorkFile.Documents.Open FileName:="C:\0.doc", ReadOnly:=True
OpenWorkFile.Visible = True
Set OpenWorkFile = Nothing
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 8220408
you could also use shellexecute api to open a document with its default app:

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 Sub Command1_Click()
Dim sFile As String
sFile = "C:\Somefile.doc"
Call ShellExecute(hwnd, "Open", (sFile), "", "C:\", 1)
End Sub
0
 

Author Comment

by:beauvoir2
ID: 8220516
Thanks.....   verry verry usefull
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

762 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