Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Issues with Word when exporting data from Excel - errorhandling

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 a 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Issues with Word when exporting data from Excel - errorhandling

I'm thinking I'd do this with Mail Merge, but wouldn't that suit your purposes?
--
HTH,
Barb Reinhardt




"Kragelund" wrote:

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 a 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Issues with Word when exporting data from Excel - errorhandlin

I haven't considered this option, and I don't know much about mail merge.
Could such a solution be controlled from Excel and run in VBA code?


"Barb Reinhardt" wrote:

I'm thinking I'd do this with Mail Merge, but wouldn't that suit your purposes?
--
HTH,
Barb Reinhardt




"Kragelund" wrote:

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 a 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting data in excel to word SKMSOffice Excel Discussion (Misc queries) 1 October 7th 09 01:44 AM
EXPORTING DATA FROM EXCEL TO WORD Akash Excel Programming 1 February 14th 07 11:08 AM
exporting data to appear at Bookmarks in a Word Document Dave Kilroy Excel Programming 0 May 19th 05 05:55 PM
exporting Excel data to Word using Bookmarks Dave Kilroy Excel Programming 0 May 19th 05 05:33 PM
How to prevent the MS Excel error dialog by errorhandling ? Oscar Excel Programming 1 January 7th 04 03:52 PM


All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"