Steve is correct and so is Tim
Tim's code permits the USER to view
the document with no option to alter the
document
BUT it also
creates a template and an odd error message
I can try to work out
this bug
the PRINT function works great
and I am sure I can load
the list box from an Access db file
Tim thanks a ton for the
code
now I and others have a very powerful working model of how to
print MS Word
documents
from Visual Basic
dwight
-----
Original Message -----
From: "Steve Manser" < smanser%40twcny.rr.com">smanser
twcny.rr.com>
To:
< helpwithvb%40yahoogroups.com">helpwithvb
yahoogroups.com>
Sent:
Monday, May 14, 2007 12:32 PM
Subject: RE: [helpwithvb] Book & MS
Word doc printing
>
> Hi,
>
> Just a
thought, but I don't think Dwight wants
> to present the User with
a real 'print preview'
> but instead he only needs to allow the
User(s)
> to see a display of the 'Read-Only' Word
document.
>
> In fact, he doesn't really need to display a
real
> Word Document, just the correct information,
perhaps
> in a Flexgrid control, or set of controls, but
then
> allow them to print-out a copy of the Word
Document.
>
> In Dwight's situation the normal 'User' or
Viewer,
> should not be allowed to make changes to the
final
> Word document.
>
> So there seems to be no
need for the Print Preview
> except when the document is being
prepared in Word,
> by the management staff
members.
>
> Most of the time Users will be viewing the
document
> and will not be printing the document every
time
> it is being viewed, by the User(s).
>
> I think
Dwight still wants the Viewer/User
> to have the option to Print
Out a copy of the
> Word Document in case they are off-site,
and
> need a hard copy for a reference.
>
> So Dwight
does need to provide a means for the User
> to navigate to where
the original document(s)
> ( Read Only ) are being stored, and
then to
> print-out the document they need in
hand.
>
> Also, since there are documents residing in a
folder,
> somewhere, Dwight needs to obtain those file
names
> so that they can be listed in the List Box
control.
>
> Does that sound about right, Dwight
?
>
> Steve
>
>
________________________________________
>
From: helpwithvb%40yahoogroups.com">helpwithvb
yahoogroups.com
>
[mailto: helpwithvb%40yahoogroups.com">helpwithvb
yahoogroups.com]
>
On Behalf Of twlewis%40softhome.net">twlewis
softhome.net
>
Sent: Monday, May 14, 2007 10:33 AM
> To: helpwithvb%40yahoogroups.com">helpwithvb
yahoogroups.com
>
Subject: Re: [helpwithvb] Book & MS Word doc
printing
>
> Dwight, look at the code below and see if
something like this will work
> for you. The form has a list box
called lstDocument, and two buttons
> called cmdPreview and cmd
Print. The code was sort of on the fly, but it
> works. It is VB6
with a reference to the MS Word 11.0 object library
> (Project
->References)
> You probably already know this, but some ask
why the need to quit Word and
> set the objects to nothing. If the
code is stopped without quitting Word
> and setting the Word
objects to nothing, an instance of winword is still
> running, and
can cause sluggishness. The instance would then have to be
>
lcosed through the task manager.
>
> Private Sub
cmdPreview_Click()
> Dim strDocument As String
>
strDocument = lstDocument.Text
> Process "Preview",
strDocument
> End Sub
>
> Private Sub
cmdPrint_Click()
> Dim strDocument As String
>
strDocument = lstDocument.Text
> Process "Print",
strDocument
> End Sub
>
> Private Sub
Form_Load()
> lstDocument.AddItem "C:My test
document.doc"
> lstDocument.AddItem "C:Dog and
cats.doc"
> End Sub
> Private Sub Process(ProcessType,
strDocument)
> Dim oWord As Word.Application
> Dim oDoc As
Word.Document
> If strDocument = "" Then
> MsgBox "Please
select a document"
> Else
> Set oWord = New
Word.Application
> oWord.Documents.Open
FileName:=strDocument, ReadOnly:=True
> Set oDoc =
oWord.ActiveDocument
> Select Case ProcessType
> Case
"Preview"
> oWord.Visible = True
> oDoc.PrintPreview
>
While oWord.PrintPreview = True
> Wend
> Case
"Print"
> oWord.Visible = False
> oDoc.PrintOut
> End
Select
> oDoc.Close
> oWord.Quit
> Set oDoc =
Nothing
> Set oWord = Nothing
> End If
> End
Sub
>
> > Adelle
> > thanks for asking
>
> after the document is selected from a list box....
>
>
> > I am still thinking about how to list these in the
list box
> > seems easy if I remember correctly
>
>
> > ....I would like the user to have the option
to
> > View the document (with no options to change the
doc)
> > and to Print after viewing ( the document )
>
> or
> > Print after selection with no Viewing
> >
(and no change to the doc permitted)
> >
> > From time
to time these documents will be edited
> > but with word and
never by the end user
> > only (edited by) a select group of
managers
> >
> > Dwight
> >
>
>
> > ----- Original Message -----
> > From:
"Adelle Hartley" < adelle%40bullet.net.au">adelle
bullet.net.au>
>
> To: < helpwithvb%40yahoogroups.com">helpwithvb
yahoogroups.com>
>
> Sent: Sunday, May 13, 2007 12:03 AM
> > Subject: RE:
[helpwithvb] Book & MS Word doc printing
> >
>
>
> >> Hi Dwight,
> >>
> >> >
I am still struggling with printing and
> >> > viewing MS
Word documents from VB 6
> >>
> >> Do you need
to "print-preview" the document, or just print it ?
> >> And
do you need to manipulate the document or
> >> just print it
from a file, "as-is" ?
> >>
> >> Adelle.
>
>>
>
>
>
>
> Yahoo! Groups
Links
>
>
>
>
>