troubleshooting Question

How do I "save as" on an open word.doc from Access 2000?

Avatar of Anthony Berenguel
Anthony BerenguelFlag for United States of America asked on
Microsoft OfficeMicrosoft AccessMicrosoft Applications
11 Comments1 Solution409 ViewsLast Modified:
Experts,

I have an Access 2000 database with a form that opens word documents using "Application.FollowHyperlink Source, , True". The use would use the form to open a word document, then they might make changes to the word.doc.

What I would like to have happen is that the user clicks a button on the access form that saves the current open word.doc with a new name, then close the word.doc. I already have the code that creates the new word.doc name. What i'm having trouble with is getting the word.doc to saveAs.

Private Sub btn_SaveWordDoc_Click()
'*********************************************************************************************
'author:        aebea
'creation date: 08/17/2011
'description:   saves word document with C1 at the end
'*********************************************************************************************
On Error GoTo error_Handler

    'declarations
    Dim Source As String
    Dim RDS_ID As String
    Dim wordApp As Word.Application
    Dim wordDoc As Word.Document
    Dim newFilename As String

    'set wordApp
    Set wordApp = CreateObject("Word.Application")
    
    'initialize RDS_ID
    RDS_ID = Me!txb_RDSID
    
    'get source by RDS_ID
    Source = DLookup("[source]", "dbo_tbl_working_table_WD1_Comments", "RDS_ID='" & RDS_ID & "'")
    
    'set wordDoc
    Set wordDoc = wordApp.Documents.Open(Source)
    
    'remove ".doc"
    Source = Replace(Source, ".doc", "")
    Debug.Print "source: " & Source

    'create new filename
    newFilename = Source & "_C1.doc"
    Debug.Print "newFilename: " & newFilename
    

    wordApp.ActiveDocument.SaveAs FileName:=newFilename, _
    AddToRecentFiles:=False

exit_Function:
Exit Sub

error_Handler:
Debug.Print "error in function:  btn_SaveWordDoc_Click()"
Debug.Print "error num: " & Err.Number & ", error desc: " & Err.Description
MsgBox "Error in Function: btn_SaveWordDoc_Click()" & vbNewLine _
    & vbNewLine _
    & "Error# " & Err.Number & ": " & Err.Description
GoTo exit_Function
End Sub

I tried to find an existing solution for my problem with the database here on EE, however I wasn't having any luck. I've been spinning my wheels on this issue form more than two weeks.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros