Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2003
    Location
    FL
    Posts
    50

    Unanswered: From Access To Word

    Hi Friends, I am back with a new problem.

    I ma created a project in Access 2000. In one of the forms, i have a link that opens word doc. Now in that word doc, I want to put the values from the access form. Meaning few of the field values from my access form I want to transfer / copy in to word document.

    Can I do that?

    If Yes How?

    Sandeep

  2. #2
    Join Date
    Jun 2002
    Posts
    173
    Here's the link I used from Microsoft. Doesn't seem to be much info on this topic other than mail merges. Microsoft has a example you can download as well. Works quite well.

    http://msdn.microsoft.com/library/de...ml/ima0102.asp

  3. #3
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    try this link
    Although it speaks of copying text to a cell you could use the word object model in place of excel.
    http://support.microsoft.com/defaul...kb;en-us;152379

  4. #4
    Join Date
    Apr 2003
    Location
    FL
    Posts
    50
    Originally posted by leeroy
    Here's the link I used from Microsoft. Doesn't seem to be much info on this topic other than mail merges. Microsoft has a example you can download as well. Works quite well.

    http://msdn.microsoft.com/library/de...ml/ima0102.asp

    Thanks a lot for your instant reply...

    I would try it today only...

    Again, I appreciate your response.

    Sandeep

  5. #5
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    Here is a function I wrote once for a database to create a new Word doc and fill in some fields to start a letter:

    Private Sub StartWordLetter_Click()
    ' Purpose: Start a Word doc w/ cur rec's name and address.

    On Error GoTo Err_StartWordLetter

    ' Dim var.
    Dim objWordApp As Word.Application
    Dim objWordDoc As Word.Document
    Dim varWordDocFileSpec As Variant
    Dim varText As Variant

    ' *** Data validation.

    ' If a blank rec, then msgbox & exit.
    If IsNull(LNCO) Then
    MsgBox "This feature can not be used on a record with a blank name.", vbExclamation
    Exit Sub
    End If

    ' *** Open Word.

    ' Open Word.
    ' Use on error resume next for GetObject() which only works if Word
    ' is already open (and thus another instance of Word is not loaded).
    On Error Resume Next
    Set objWordApp = GetObject(, "Word.Application")
    ' If Word not already opened (GetObject error of 429).
    If Err.Number = 429 Then
    Set objWordApp = CreateObject("Word.Application")
    End If
    ' Set error handler back to normal
    On Error GoTo Err_StartWordLetter

    ' Make app. visible and maximized.
    objWordApp.Visible = True
    objWordApp.WindowState = wdWindowStateMaximize

    ' Make the Word app have the focus.
    ' (This step needed if Word was already open before this
    ' subroutine was run.)
    AppActivate "Microsoft Word"

    ' *** Create Word Doc.

    ' Create datafile.
    Set objWordDoc = objWordApp.Documents.Add

    '*** Add What's Needed to Word Doc.

    ' New line(s).
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph

    ' Date.
    ' (Example: December 1, 1999)
    objWordApp.Selection.TypeText Text:=Format$(Date, "mmmm d, yyyy")

    ' New line(s).
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph

    ' Name & Address.

    ' Full name.
    varText = Nz(BuildFullName(Me!TITL, Me!FN, Me!MI, Me!LNCO, Me!Jr))
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph

    ' Street address lines.
    If Not IsNull(Me!ADD1) Then
    varText = Me!ADD1
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph
    End If

    If Not IsNull(Me!ADD2) Then
    varText = Me!ADD2
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph
    End If

    If Not IsNull(Me!ADD3) Then
    varText = Me!ADD3
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph
    End If

    If Not IsNull(Me!ADD4) Then
    varText = Me!ADD4
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph
    End If

    ' City/State/Zip.
    varText = Nz(BuildCityStateZip(Me!CITY, Me!ST_P, Me!ZCD))
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph

    ' Country.
    If Not IsNull(Me!CTRY) Then
    varText = Me!CTRY
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph
    End If

    ' New line(s).
    objWordApp.Selection.TypeParagraph

    ' Dear ___:
    varText = Nz(BuildSalutationName(Me!TITL, Me!LNCO))
    varText = "Dear " & varText & ":"
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph

    ' New line(s).
    objWordApp.Selection.TypeParagraph

    Exit Sub

    Err_StartWordLetter:
    MsgBox "Error " & Err & "." & Chr(13) & Chr(10) & Chr(10) & Err.Description & ".", vbExclamation
    Exit Sub

    End Sub
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

  6. #6
    Join Date
    Apr 2003
    Location
    FL
    Posts
    50
    Originally posted by Bullschmidt
    Here is a function I wrote once for a database to create a new Word doc and fill in some fields to start a letter:

    Private Sub StartWordLetter_Click()
    ' Purpose: Start a Word doc w/ cur rec's name and address.

    On Error GoTo Err_StartWordLetter

    ' Dim var.
    Dim objWordApp As Word.Application
    Dim objWordDoc As Word.Document
    Dim varWordDocFileSpec As Variant
    Dim varText As Variant

    ' *** Data validation.

    ' If a blank rec, then msgbox & exit.
    If IsNull(LNCO) Then
    MsgBox "This feature can not be used on a record with a blank name.", vbExclamation
    Exit Sub
    End If

    ' *** Open Word.

    ' Open Word.
    ' Use on error resume next for GetObject() which only works if Word
    ' is already open (and thus another instance of Word is not loaded).
    On Error Resume Next
    Set objWordApp = GetObject(, "Word.Application")
    ' If Word not already opened (GetObject error of 429).
    If Err.Number = 429 Then
    Set objWordApp = CreateObject("Word.Application")
    End If
    ' Set error handler back to normal
    On Error GoTo Err_StartWordLetter

    ' Make app. visible and maximized.
    objWordApp.Visible = True
    objWordApp.WindowState = wdWindowStateMaximize

    ' Make the Word app have the focus.
    ' (This step needed if Word was already open before this
    ' subroutine was run.)
    AppActivate "Microsoft Word"

    ' *** Create Word Doc.

    ' Create datafile.
    Set objWordDoc = objWordApp.Documents.Add

    '*** Add What's Needed to Word Doc.

    ' New line(s).
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph

    ' Date.
    ' (Example: December 1, 1999)
    objWordApp.Selection.TypeText Text:=Format$(Date, "mmmm d, yyyy")

    ' New line(s).
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph
    objWordApp.Selection.TypeParagraph

    ' Name & Address.

    ' Full name.
    varText = Nz(BuildFullName(Me!TITL, Me!FN, Me!MI, Me!LNCO, Me!Jr))
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph

    ' Street address lines.
    If Not IsNull(Me!ADD1) Then
    varText = Me!ADD1
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph
    End If

    If Not IsNull(Me!ADD2) Then
    varText = Me!ADD2
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph
    End If

    If Not IsNull(Me!ADD3) Then
    varText = Me!ADD3
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph
    End If

    If Not IsNull(Me!ADD4) Then
    varText = Me!ADD4
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph
    End If

    ' City/State/Zip.
    varText = Nz(BuildCityStateZip(Me!CITY, Me!ST_P, Me!ZCD))
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph

    ' Country.
    If Not IsNull(Me!CTRY) Then
    varText = Me!CTRY
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph
    End If

    ' New line(s).
    objWordApp.Selection.TypeParagraph

    ' Dear ___:
    varText = Nz(BuildSalutationName(Me!TITL, Me!LNCO))
    varText = "Dear " & varText & ":"
    objWordApp.Selection.TypeText Text:=varText
    objWordApp.Selection.TypeParagraph

    ' New line(s).
    objWordApp.Selection.TypeParagraph

    Exit Sub

    Err_StartWordLetter:
    MsgBox "Error " & Err & "." & Chr(13) & Chr(10) & Chr(10) & Err.Description & ".", vbExclamation
    Exit Sub

    End Sub

    Thanks... I would try this too. Hope this would work better with less efforts... let's see... But thanks a lot anyways...

  7. #7
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    the easiest way without cod ewould be to create a mail merge document.
    Insert the record that is on the form into table so only one record is in the table at a time. launch the word document that is linked to the table and your fields data will appear on the word doc.

    does that make sense?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •