Hi!
I'm working on a macro that copies data from Excel and then pastes it to Word, after which it saves the document.
Here's the code:
Sub PasteToWord()
Range("A5:A6").Select
Dim WDApp As Word.Application
' Is something selected?
If Not TypeName(Selection) = "Range" Then
MsgBox "Select a Range!", vbExclamation, "No Range Selected"
Else
Set WDApp = CreateObject "Word.Application.9")
WDApp.Visible = True
Selection.copy
WDApp.Documents.Add
WDApp.Selection.Paste
WDApp.ActiveDocument.SaveAs FileName:="C:tempImported.doc"
WDApp.ActiveDocument.Close
Set WDDoc = Nothing
Set WDApp = Nothing
End If
End Sub
Now, I've managed to make it work, but I've got 2 questions:
1. How can I get the macro NOT to copy the cell outlines to the Word document?
2. How do define the empty space left between the words that are pasted to the document?
This message was edited by SnowBlind on 2002-07-11 05:31
I'm working on a macro that copies data from Excel and then pastes it to Word, after which it saves the document.
Here's the code:
Sub PasteToWord()
Range("A5:A6").Select
Dim WDApp As Word.Application
' Is something selected?
If Not TypeName(Selection) = "Range" Then
MsgBox "Select a Range!", vbExclamation, "No Range Selected"
Else
Set WDApp = CreateObject "Word.Application.9")
WDApp.Visible = True
Selection.copy
WDApp.Documents.Add
WDApp.Selection.Paste
WDApp.ActiveDocument.SaveAs FileName:="C:tempImported.doc"
WDApp.ActiveDocument.Close
Set WDDoc = Nothing
Set WDApp = Nothing
End If
End Sub
Now, I've managed to make it work, but I've got 2 questions:
1. How can I get the macro NOT to copy the cell outlines to the Word document?
2. How do define the empty space left between the words that are pasted to the document?
This message was edited by SnowBlind on 2002-07-11 05:31