Solved

Opening Word document

Posted on 2003-12-07
7
1,070 Views
Last Modified: 2010-05-03
Hi !

How do i open a Word document ?
I use this :
===============================
Dim MyDoc As Word.Application

Set MyDoc = New Word.Application
MyDoc.Documents.Open ("c:\TP2\facture.doc")
===============================
It works great but i never actually see the Word document.
I'm adding data in it but it seems as if the transfer was done
in the background....
Is there any way that i could open the Word document once
the transfer is done ???

Also, when the file is already opened i have that read-only
warning message. How can i get rid of it ???

Thanks !
0
Comment
Question by:rouxjean
[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
  • 4
  • 2
7 Comments
 
LVL 24

Expert Comment

by:shivsa
ID: 9892513
Dim MyDoc As Word.Application
     
    Set MyDoc = CreateObject("Word.Application")
    MyDoc.Documents.Open "c:\TP2\facture.doc"
    MyDoc.Visible = True

---------------------
0
 
LVL 24

Accepted Solution

by:
shivsa earned 500 total points
ID: 9892529
if u want to open the word file stored as a variable by clicking a button on the form.

set a reference to MS word object lib in your project and add this code :

Private Sub Command1_Click()

Dim MyApp As Object
Dim MyDoc As Object
Set MyApp = CreateObject("Word.Application")
Set myDoc = MyApp.Documents.Open("C:\TP2\facture.doc")
MyApp.Visible = True

End Sub
0
 

Author Comment

by:rouxjean
ID: 9892828
Thx :)
and how about the warning message ?
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 24

Expert Comment

by:shivsa
ID: 9892920
------------------------------
Dim MyApp As Object
Set MyApp = CreateObject("Word.Application")
MyApp.Visible = True
MyApp.Documents.Open FileName:="C:\data\gems.doc", ConfirmConversions:=False, ReadOnly:=False
Set MyApp = Nothing
------------------------------
0
 

Author Comment

by:rouxjean
ID: 9893071
It still pops the message !
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9893425
u have to write code to handle the error.
check for its attributes wheteher it is a read only or anything.. then you can handle the error.
you can use the filesystemobject implementing this.

whenever u open a word doc, and some other opens it  lock the file and second application get it as a read only warning.
0
 
LVL 1

Expert Comment

by:sonikthomas
ID: 9895176
set mydoc visible
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

726 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