Solved

Opening Word document

Posted on 2003-12-07
7
1,066 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
  • 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 …
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 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

17 Experts available now in Live!

Get 1:1 Help Now