alastair69
Registered User.
- Local time
- Today, 04:49
- Joined
- Dec 21, 2004
- Messages
- 562
Hello One and All,
I have a problem, with bookmarks into a word document. I have spent three days looking at the search function and i have not found any help.
I have a database the uses a report number to filter on samples taken, this works fine and all the right samples are displayed when clicking on the report number. I need the samples to be sent to word in a table.
I have gone though the word document and setup book marks for all the lines of data i need to show, i have then created a button to press that will send the data though to the word document, all works exept for some reason only one line of data appreas. This is the only selected item via the sub form, so i thought right i will add a tick box as the tricker but even these does not help.
The code i am useing is below, i am at by limits with this and need some help from you lot out there.
-------------------------------------------------------------------------------
CODE
Private Sub cmd_Word_Template_Click()
'Declare the follwing
Dim objWord As Word.Application
'Set word as an application and make it invisible
Set objWord = CreateObject("Word.Application")
objWord.Visible = False 'True is visible
'path and name of the template your are using.
objWord.Documents.Add ("C:\Temp\SamplesForm.dot")
'This is for the bookmark that you created in the template
objWord.ActiveDocument.Bookmarks("SampleNumber").Select
'This is the field in access that containts the data that has to be entered at the
'bookmark
objWord.Selection.Text = Forms![main form]![frm Export]![Sample]
'This is for the bookmark that you created in the template
objWord.ActiveDocument.Bookmarks("SampleLocation").Select
'This is the field in access that containts the data that has to be entered at the
'bookmark
objWord.Selection.Text = Forms![main form]![frm Export]![SampleLocation]
'This is for the bookmark that you created in the template
objWord.ActiveDocument.Bookmarks("Result").Select
'This is the field in access that containts the data that has to be entered at the
'bookmark
objWord.Selection.Text = Forms![main form]![frm Export]![Results]
'Word (or the document that you created with the template, will now open)
objWord.Visible = True
Set objWord = Nothing
End Sub
I have a problem, with bookmarks into a word document. I have spent three days looking at the search function and i have not found any help.
I have a database the uses a report number to filter on samples taken, this works fine and all the right samples are displayed when clicking on the report number. I need the samples to be sent to word in a table.
I have gone though the word document and setup book marks for all the lines of data i need to show, i have then created a button to press that will send the data though to the word document, all works exept for some reason only one line of data appreas. This is the only selected item via the sub form, so i thought right i will add a tick box as the tricker but even these does not help.
The code i am useing is below, i am at by limits with this and need some help from you lot out there.
-------------------------------------------------------------------------------
CODE
Private Sub cmd_Word_Template_Click()
'Declare the follwing
Dim objWord As Word.Application
'Set word as an application and make it invisible
Set objWord = CreateObject("Word.Application")
objWord.Visible = False 'True is visible
'path and name of the template your are using.
objWord.Documents.Add ("C:\Temp\SamplesForm.dot")
'This is for the bookmark that you created in the template
objWord.ActiveDocument.Bookmarks("SampleNumber").Select
'This is the field in access that containts the data that has to be entered at the
'bookmark
objWord.Selection.Text = Forms![main form]![frm Export]![Sample]
'This is for the bookmark that you created in the template
objWord.ActiveDocument.Bookmarks("SampleLocation").Select
'This is the field in access that containts the data that has to be entered at the
'bookmark
objWord.Selection.Text = Forms![main form]![frm Export]![SampleLocation]
'This is for the bookmark that you created in the template
objWord.ActiveDocument.Bookmarks("Result").Select
'This is the field in access that containts the data that has to be entered at the
'bookmark
objWord.Selection.Text = Forms![main form]![frm Export]![Results]
'Word (or the document that you created with the template, will now open)
objWord.Visible = True
Set objWord = Nothing
End Sub