K
Kragelund
Hi,
interesting to read the threads on exporting data from Excel to Word. I am
trying to autogenerate a Word report populated with data from Excel 2007, but
I meet a few obstacles.
My questions are: how do I avoid that the procedure of exporting data stops,
when it encounters an empty cell in Excel?
When the same piece of data in Excel has to be exported to various places in
the document, I apparently can't use the same bookmark in Word. Is there a
way around this.
Thanks in advance!
The code:
Sub Report_Xl_to_Word()
Dim WordRep As Object
Set WordRep = CreateObject("Word.Application")
WordRep.Documents.Open "J:\Plan_something.doc"
WordRep.Visible = True
worksheets("Statusark").Range("c63").Copy
WordRep.Selection.GoTo what:=wdGoToBookmark, name:="Plantype"
WordRep.Selection.PasteSpecial Link:=False, DataType:=wdPasteText,
Placement:=wdInLine, DisplayAsIcon:=False
worksheets("Statusark").Range("c64").Copy
WordRep.Selection.GoTo what:=wdGoToBookmark, name:="Resume_dato"
WordRep.Selection.PasteSpecial Link:=False, DataType:=wdPasteText,
Placement:=wdInLine, DisplayAsIcon:=False
worksheets("Statusark").Range("c65").Copy
WordRep.Selection.GoTo what:=wdGoToBookmark, name:="PR1"
WordRep.Selection.PasteSpecial Link:=False, DataType:=wdPasteText,
Placement:=wdInLine, DisplayAsIcon:=False
....
Application.CutCopyMode = False
Set WordRep = Nothing
End Sub
interesting to read the threads on exporting data from Excel to Word. I am
trying to autogenerate a Word report populated with data from Excel 2007, but
I meet a few obstacles.
My questions are: how do I avoid that the procedure of exporting data stops,
when it encounters an empty cell in Excel?
When the same piece of data in Excel has to be exported to various places in
the document, I apparently can't use the same bookmark in Word. Is there a
way around this.
Thanks in advance!
The code:
Sub Report_Xl_to_Word()
Dim WordRep As Object
Set WordRep = CreateObject("Word.Application")
WordRep.Documents.Open "J:\Plan_something.doc"
WordRep.Visible = True
worksheets("Statusark").Range("c63").Copy
WordRep.Selection.GoTo what:=wdGoToBookmark, name:="Plantype"
WordRep.Selection.PasteSpecial Link:=False, DataType:=wdPasteText,
Placement:=wdInLine, DisplayAsIcon:=False
worksheets("Statusark").Range("c64").Copy
WordRep.Selection.GoTo what:=wdGoToBookmark, name:="Resume_dato"
WordRep.Selection.PasteSpecial Link:=False, DataType:=wdPasteText,
Placement:=wdInLine, DisplayAsIcon:=False
worksheets("Statusark").Range("c65").Copy
WordRep.Selection.GoTo what:=wdGoToBookmark, name:="PR1"
WordRep.Selection.PasteSpecial Link:=False, DataType:=wdPasteText,
Placement:=wdInLine, DisplayAsIcon:=False
....
Application.CutCopyMode = False
Set WordRep = Nothing
End Sub