View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default linking a averaged cell sum to a specific spot in a word document

There are many ways to do this; this is probably the easiest:

Sub OpenAWordFile()
Dim wordApp As Object
Dim fNameAndPath As String
ActiveSheet.Range("A1:A2").Copy
fNameAndPath = "C:\Test\MyFile.doc"
Set wordApp = CreateObject("Word.Application")
With wordApp
..Documents.Open (fNameAndPath)
..Visible = True
..Selection.PasteSpecial DataType:=wdPasteText
'.Selection.PasteAndFormat (wdPasteDefault)
..Selection.WholeStory
..Selection.Font.Name = "Arial"
..Selection.Font.Size = 11
End With
Set wordApp = Nothing
Application.CutCopyMode = False
End Sub

Notice: you must have a blank word file saved in this location:
C:\Test\MyFile.doc


You can give this a try too:
Sub OpenAWordFile()
Dim wdApp As Object
Dim wdDoc As Object
Dim fNameAndPath As String
fNameAndPath = "C:\Test\MyFile.doc"
ActiveSheet.Range("A1:D4").Copy
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err.Number < 0 Then
Set wdApp = CreateObject("Word.Application")
End If
Err.Clear
On Error GoTo 0
Set wdDoc = wdApp.Documents.Open(fNameAndPath)
wdApp.Visible = True
With wdDoc.Content
..Font.Name = "Arial"
..Font.Size = 11
..PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False
End With
End Sub


Regards,
Ryan---


--
RyGuy


"Karyn" wrote:

how do i link an averaged cell to a specific spot in a word document, I tried
the copy then paste as a hyper link but it did not work.