[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Opening a word document in word from VB

Posted on 2003-03-27
3
Medium Priority
?
161 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
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

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

612 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