P
Peter Stone
I've posted this twice in Access forms coding and had no luck. Maybe someone
here can help me. Thanks.
Novice Word 2003, Access 2003, XP Pro
I have some four subforms each with a command button that opens a document
in MS Word and renames it.
The user then enters or adds text to the Word document. When they close
Word, I want to save the text in the Word document into a memo field in
Access.
I don't know how to pass the control name to MS Word and then save the text
back to that control.
I don't want to use the form names so that the subforms can be used in
multiple main forms.
***Here's the controls:
frmMain!fsubPub1.Form!txtPub1
frmMain!fsubPub2.Form!txtPub2
frmMain!fsubPub3.Form!txtPub3
frmMain!fsubPub4.Form!txtPub4
***Here's the code on the command button on one subform:
Private Sub cmdOpenPub1_Click()
On Error GoTo Err_cmdOpenPub1_Click
Dim oWord As Object
Dim oDoc As Object
'Create the Word application object
Set oWord = CreateObject("Word.Application")
If Me!txtPubLnk1 = "C:\t2hDoc\StartHere.Doc" Then
'Open a new document
Set oDoc = oWord.Documents.Add("C:\t2hDoc\StartHere.doc")
'Rename and save the new document
oWord.ActiveDocument.SaveAs Filename:="C:\t2hDoc\Folder\Another
Folder\etc.\" _
& Me.Parent!txtHd.Value & "_" & "Main".doc"
'Store the link to the new document
Me!txtPubLnk1 = "C:\t2hDoc\Folder\Another Folder\etc.\"
& Me.Parent!txtHd.Value & "_" & "Main".doc"
Me.Requery
Else
'Open the existing document
Set oDoc = oWord.Documents.Open(Me!txtPubLnk1.Value)
End If
CODE NEEDED HERE
'Display MS-Word and release the document object
oWord.Visible = True
Set oWord = Nothing
End Sub
***Here's the code in MS Word that selects and copies the text:
Private Sub Document_Close()
Selection.WholeStory
Selection.Copy
CODE NEEDED HERE
End Sub
Thank you
Peter
here can help me. Thanks.
Novice Word 2003, Access 2003, XP Pro
I have some four subforms each with a command button that opens a document
in MS Word and renames it.
The user then enters or adds text to the Word document. When they close
Word, I want to save the text in the Word document into a memo field in
Access.
I don't know how to pass the control name to MS Word and then save the text
back to that control.
I don't want to use the form names so that the subforms can be used in
multiple main forms.
***Here's the controls:
frmMain!fsubPub1.Form!txtPub1
frmMain!fsubPub2.Form!txtPub2
frmMain!fsubPub3.Form!txtPub3
frmMain!fsubPub4.Form!txtPub4
***Here's the code on the command button on one subform:
Private Sub cmdOpenPub1_Click()
On Error GoTo Err_cmdOpenPub1_Click
Dim oWord As Object
Dim oDoc As Object
'Create the Word application object
Set oWord = CreateObject("Word.Application")
If Me!txtPubLnk1 = "C:\t2hDoc\StartHere.Doc" Then
'Open a new document
Set oDoc = oWord.Documents.Add("C:\t2hDoc\StartHere.doc")
'Rename and save the new document
oWord.ActiveDocument.SaveAs Filename:="C:\t2hDoc\Folder\Another
Folder\etc.\" _
& Me.Parent!txtHd.Value & "_" & "Main".doc"
'Store the link to the new document
Me!txtPubLnk1 = "C:\t2hDoc\Folder\Another Folder\etc.\"
& Me.Parent!txtHd.Value & "_" & "Main".doc"
Me.Requery
Else
'Open the existing document
Set oDoc = oWord.Documents.Open(Me!txtPubLnk1.Value)
End If
CODE NEEDED HERE
'Display MS-Word and release the document object
oWord.Visible = True
Set oWord = Nothing
End Sub
***Here's the code in MS Word that selects and copies the text:
Private Sub Document_Close()
Selection.WholeStory
Selection.Copy
CODE NEEDED HERE
End Sub
Thank you
Peter