code to create/modify word document from access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jayne
    New Member
    • Sep 2006
    • 2

    #1

    code to create/modify word document from access

    I have created the following code the first part works to create a word document with but when I have created the document and existed word, I then click the button again to open up the document to edit it, it opens the document but as a new one again. Fairly new to this so any help would be appreciated.

    Private Sub Command132_Clic k()
    DoCmd.Save

    Dim LWordDoc As String
    Dim oApp As Object
    Dim strFilename As String
    Dim strFilename1 As String


    'Path to the word document
    ' LWordDoc = "c:\building_co ntrol\export\" & strFilename1 & "_" & strFilename
    LWordDoc = "c:\building_co ntrol\export\" & strFilename1 & "_" & strFilename & ".doc"

    strFilename = Me.inspection
    strFilename1 = Me.job



    If Dir(LWordDoc) = "" Then


    Set oApp = CreateObject("W ord.Application ")
    oApp.Visible = True
    oApp.Documents. Add

    oApp.WindowStat e = wdWindowStateMa ximize '
    oApp.ActiveDocu ment.SaveAs FileName:="c:\b uilding_control \export\" & strFilename1 & "_" & strFilename

    'Forms!inspecti on_details!word _document = Forms!inspectio n_details!job & "_" & Forms!inspectio n_details!inspe ction & ".doc" ''



    Else


    'Open the Document
    application.Fol lowHyperlink "c:\building_co ntrol\export\" & strFilename1 & "_" & strFilename & ".doc"


    End If

    End Sub
Working...