Question Open txt document from ms access

josephbupe

Registered User.
Local time
Today, 23:37
Joined
Jan 31, 2008
Messages
247
Hi,

I am attempting to open .txt files (with a notepad) from access following the hint at http://www.databasedev.co.uk/open_word_doc.html

But, I am getting an error "ActiveX component cant create object", which is taking me to the line in the module
Code:
Set objApp = CreateObject("notepad.Application")

Here is what I have:

Module:
Code:
Sub OpenWordDoc(strDocName As String)
    Dim objApp As Object

    'Opens the document

    Set objApp = CreateObject("notepad.Application")
    objApp.Visible = True
    objApp.Documents.Open strDocName
End Sub

Code:
Private Sub cmdOpenDoc_Click()
'Check to see that there is a document file path associated with the record
    If IsNull(Me.FilePath) Or Me.FilePath = "" Then
        MsgBox "Please Ensure There Is A File Path Associated " & _
        "For This Document", _
               vbInformation, "Action Cancelled"
'        Exit Sub
'    Else
        'Check that the document specified in the file path is actually there
'        If (Dir(Me.FilePath) = "") Then
'            MsgBox "Document Does Not Exist In The Specified Location", _
'                   vbExclamation, "Action Cancelled"
            Exit Sub
        Else
            'Opens document in Word
            Call OpenWordDoc(Me.FilePath)
    
     
'        End If
    End If
End Sub

I will appreciate your help.

Joseph
 
For what purpose? There are ways and means, but the purpose of opening the text file from access is significant
 
Will this not do?

Code:
Shell "notepad " & me.filepath, vbNormalFocus

Obviously you still need to deal with the error catching.

Chris
 
FollowHyperlink "path", , True

works fine too, but again, for what purpose?
 
Thanx for your responses.

As to for what purpose I am attempting to open .txt documents? Well, it is a system for tracking criminal cases associated with theft of motor vehicles. Each record has a txt file I want associated to it. In a nut shell, for the same purpose as explained at databasedev.co.uk website, except that i am not storing word doc but .txt files.

Joseph
 

Users who are viewing this thread

Back
Top Bottom