Select the whole of a word document to copy

J

justagrunt

Hi,
How do I select the whole of a word document so that I can copy it.
What do I use to copy it as I have tried "wordapp.copy"
 
D

Doug Robbins - Word MVP

Use ActiveDocument.Range

If you use the Range object, there is no need to select it.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

justagrunt

Hi doug,
I have tried the following
ActiveDocument.Range.copy - in the following

If (Me![Section11]) = True Then ' this is on the control on the access
form
'do something
Set WordDoc =
WordApp.Documents.Open("C:\Database\25KgPowder\Section11.doc")
WordDoc.Visible = False
'copy contents for pasting into original document
ActiveDocument.Range.Copy
'???????????????????
'close the "Section11" document as not required anymore
ActiveDocument.close wdDoNotSaveChanges
'paste this section to the template
'bring original document to focus
'locate the bookmark and paste section11
Set WordDoc = WordApp.Documents.Open("C:\Database\25KgPowder\Base.doc")
Set WordDoc = WordApp.ActiveDocument
Set WordRng = WordDoc.GoTo(what:=wdGoToBookmark, NAME:="frmBookmark")
'paste
WordDoc.Add.Content.Paste
Else
'do something
End If

The Document opens - is visible when I thought it wouldn't be - stays open
and doesn't appear to do anything.
The other document is there also.
The other document doesn't have the added parts.
Suggestions please.
--
Regards
Bill


Doug Robbins - Word MVP said:
Use ActiveDocument.Range

If you use the Range object, there is no need to select it.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

justagrunt

Hi Doug,
Sorry for the last post - sound like a trumpet call - distraction.
The code is, and somthings not working, getting error 438 description ;
object doesn't support this property or method - but don't know where.

If (Me![Section11]) = True Then
'do something
Set WordDoc =
WordApp.Documents.Open("C:\Database\25KgPowder\Section11.doc")
WordDoc.Visible = False
'copy contents for pasting into original document
ActiveDocument.Range.Copy
'???????????????????
'close the "Section11" document as not required anymore
ActiveDocument.close wdDoNotSaveChanges
'paste this section to the template
'bring original document to focus
'locate the bookmark and paste section11
Set WordDoc = WordApp.Documents.Open("C:\Database\25KgPowder\Base.doc")
Set WordDoc = WordApp.ActiveDocument
Set WordRng = WordDoc.GoTo(what:=wdGoToBookmark, NAME:="frmBookmark")
'paste
WordDoc.Add.Content.Paste
Else
'do something
End If

'set up mail merge of access fields to word.
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("25Kg", dbOpenDynaset)
dteTodayDate = Format(Date, "dd-mmm-yyyy")

' get rid of any null values in the fields
With rst
CompanyName = Nz(![CompanyName])
CompanyName1 = Nz(![CompanyName])
By = Nz(![Quotation by])
By1 = Nz(![Quotation by])
Address1 = Nz(![Address1])
Address2 = Nz(![Address2])
Address3 = Nz(![Address3])
Address4 = Nz(![Address4])
Address5 = Nz(![Address5])
Country = Nz(![Country])
ProjectName = Nz(![ProjectName])
ProjectName1 = Nz(![ProjectName])
ContactName = Nz(![ContactName])
LandPhone = Nz(![LandPhone])
FaxNumber = Nz(![FaxNumber])
QuoteRef = Nz(![QuoteRef])
End With

'write information to Word custom document properties from
'previously created variables

Set prps = WordDoc.CustomDocumentProperties
prps.Item("CompanyName").Value = CompanyName
prps.Item("CompanyName1").Value = CompanyName1
prps.Item("By").Value = By
prps.Item("By1").Value = By1
prps.Item("Address1").Value = Address1
prps.Item("Address2").Value = Address2
prps.Item("Address3").Value = Address3
prps.Item("Address4").Value = Address4
prps.Item("Address5").Value = Address5
prps.Item("Country").Value = Country
prps.Item("dteTodayDate").Value = dteTodayDate
prps.Item("ProjectName").Value = ProjectName
prps.Item("ProjectName1").Value = ProjectName1
prps.Item("ContactName").Value = ContactName
prps.Item("QuoteRef").Value = QuoteRef

'highlight the entire word document and update fields, so the data
'written to the custom doc props is disoplayed in the DocVariables fields
objWord.Selection.WholeStory
objWord.Selection.Fields.Update
objWord.Selection.HomeKey unit:=6
objWord.Visible = True
objWord.Activate

Parts of this are taken from MS publishing "Access 2002" the complete in and
out.
So I figure my problem is in the copy and paste part - what do I know.
Both Documents are visible - and nothing has been copied or pasted.

Suggestion????


--
Regards
Bill


Doug Robbins - Word MVP said:
Use ActiveDocument.Range

If you use the Range object, there is no need to select it.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top