PC Review


Reply
Thread Tools Rate Thread

Can't view a word document.

 
 
Shipp
Guest
Posts: n/a
 
      2nd Sep 2003
I have the following code in a module. When I execute the
code Word is loaded and is visible. However, the document
that is declared in strDOC does not load up automatically.
Any help would be appreciated.

Private Sub btnWord_Click()

On Error GoTo Err_btnWord_Click

Dim strDir As String
Dim strDoc As String
Dim strTyp As String
Dim strFul As String
Dim objWord As Word.Document

strDir = Forms!frmConHdr!sfrmDocuments.Form.Directory
strDoc = Forms!frmConHdr!sfrmDocuments.Form.FileName
strTyp = Forms!frmConHdr!sfrmDocuments.Form.cboType
strFul = strDir & strDoc & "." & strTyp

Set objWord = GetObject(strFul)
objWord.Application.Visible = True

Exit_btnWord_Click:
Exit Sub

Err_btnWord_Click:
MsgBox Err.Description
Resume Exit_btnWord_Click

End Sub

 
Reply With Quote
 
 
 
 
TC
Guest
Posts: n/a
 
      3rd Sep 2003

Why would you *expect* the document in strDOC to be loaded automatically?
How would Word possibly know that you wanted that to happen? How would it
know that strDOC held the document name, and not strDir, or strTyp?

You have to *tell* Word to open the document, by using the appropriate Word
method; OPEN, I guess - I do not have Word here to check.

Something like:

> Set objWord = GetObject(strFul)
> objWord.Application.Visible = True

objWord.Open strDOC

HTH,
TC


"Shipp" <(E-Mail Removed)> wrote in message
news:00a901c37179$0bf9d610$(E-Mail Removed)...
> I have the following code in a module. When I execute the
> code Word is loaded and is visible. However, the document
> that is declared in strDOC does not load up automatically.
> Any help would be appreciated.
>
> Private Sub btnWord_Click()
>
> On Error GoTo Err_btnWord_Click
>
> Dim strDir As String
> Dim strDoc As String
> Dim strTyp As String
> Dim strFul As String
> Dim objWord As Word.Document
>
> strDir = Forms!frmConHdr!sfrmDocuments.Form.Directory
> strDoc = Forms!frmConHdr!sfrmDocuments.Form.FileName
> strTyp = Forms!frmConHdr!sfrmDocuments.Form.cboType
> strFul = strDir & strDoc & "." & strTyp
>
> Set objWord = GetObject(strFul)
> objWord.Application.Visible = True
>
> Exit_btnWord_Click:
> Exit Sub
>
> Err_btnWord_Click:
> MsgBox Err.Description
> Resume Exit_btnWord_Click
>
> End Sub
>



 
Reply With Quote
 
Matthew
Guest
Posts: n/a
 
      3rd Sep 2003
Hi - this works :

Private Sub Command21_Click()
Dim strCmd As String

strCmd = """C:\Program Files\Common Files\Microsoft
Shared\PhotoEd\Photoed.exe"""
strCmd = strCmd & """" & Me![FilePathName] & """"
Shell strCmd
End Sub

Substitute winword.exe for PhotoEd.exe. FilePathName
refers to my table field which stores the file and
pathname (duh). Click on a command button with this code
in your on-click and bingo

Matthew


>-----Original Message-----
>I have the following code in a module. When I execute the
>code Word is loaded and is visible. However, the document
>that is declared in strDOC does not load up

automatically.
>Any help would be appreciated.
>
>Private Sub btnWord_Click()
>
> On Error GoTo Err_btnWord_Click
>
> Dim strDir As String
> Dim strDoc As String
> Dim strTyp As String
> Dim strFul As String
> Dim objWord As Word.Document
>
> strDir = Forms!frmConHdr!sfrmDocuments.Form.Directory
> strDoc = Forms!frmConHdr!sfrmDocuments.Form.FileName
> strTyp = Forms!frmConHdr!sfrmDocuments.Form.cboType
> strFul = strDir & strDoc & "." & strTyp
>
> Set objWord = GetObject(strFul)
> objWord.Application.Visible = True
>
>Exit_btnWord_Click:
> Exit Sub
>
>Err_btnWord_Click:
> MsgBox Err.Description
> Resume Exit_btnWord_Click
>
>End Sub
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I simply view the document map of a document in Word 2007? Brian B Microsoft Word Document Management 1 26th Mar 2009 04:55 PM
how to view a word document 2007 when i only have word 2003? =?Utf-8?B?RGFreQ==?= Microsoft Word Document Management 2 11th Feb 2007 06:35 PM
Only 'VIEW' Word document. =?Utf-8?B?a3dtNTMyMQ==?= Microsoft Word Document Management 2 1st May 2006 10:27 PM
Unable to View Word 2000 Document with Word 2002 Kellie Microsoft Word Document Management 1 21st Sep 2004 10:29 AM
View a Word Document =?Utf-8?B?U3dhbWluYXRoYW4=?= Microsoft Word Document Management 3 27th Feb 2004 04:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:09 AM.