Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Macro copying an array and pasting to a Word bookmark

I have a macro which I'd like to extract data from a sheet, copy the
resultant array to a bookmark in an open Word template and it falls over
(before it gets started) with 'Compile error: user-defined type not defined'.

Here's the relevant part:
Sheets("2.1. ").Select
Application.Goto Reference:="Totals"
Application.Run "'ET Utilities.xls'!xtractFromStd"
Selection.CurrentRegion.Select
Selection.Cut
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("I:\I:\ET\Report Template.dot")
With wrdDoc
Dim BmkNm As String
BmkNm = "S1"
End With

The crunch seems to be in wrdApp As Word.Application.

I'm sure it's very basic to you guys but any clues gratefully received by a
raw beginner.
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default Macro copying an array and pasting to a Word bookmark

Hi Jimbob,

apart form other issues,
which will be addressed in the next question, IMHO,

Dim wrdApp As Word.Application


alone is not sufficient.

There has to be 'getobject' or 'createobject' in addition,
like for an already running instance of Word:

Dim wrdApp As Word.Application
set wrdApp = getobject(, "Word.Application")

With wrdDoc
Dim BmkNm As String
BmkNm = "S1"
End With


Doesn't affect Word at all.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Macro copying an array and pasting to a Word bookmark

Try Tools - References

Select Microsoft Word 11.0 Object Librarty

(At least that's what I have on my machine)

HTH,
Barb Reinhardt

"Jimbob" wrote:

I have a macro which I'd like to extract data from a sheet, copy the
resultant array to a bookmark in an open Word template and it falls over
(before it gets started) with 'Compile error: user-defined type not defined'.

Here's the relevant part:
Sheets("2.1. ").Select
Application.Goto Reference:="Totals"
Application.Run "'ET Utilities.xls'!xtractFromStd"
Selection.CurrentRegion.Select
Selection.Cut
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("I:\I:\ET\Report Template.dot")
With wrdDoc
Dim BmkNm As String
BmkNm = "S1"
End With

The crunch seems to be in wrdApp As Word.Application.

I'm sure it's very basic to you guys but any clues gratefully received by a
raw beginner.
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Macro copying an array and pasting to a Word bookmark

Thanks Barb. I had this selected as I saw other postings with this
recommendation so I think the answer lies elsewhere but thanks for your
response.
Jimbob

"Barb Reinhardt" wrote:

Try Tools - References

Select Microsoft Word 11.0 Object Librarty

(At least that's what I have on my machine)

HTH,
Barb Reinhardt

"Jimbob" wrote:

I have a macro which I'd like to extract data from a sheet, copy the
resultant array to a bookmark in an open Word template and it falls over
(before it gets started) with 'Compile error: user-defined type not defined'.

Here's the relevant part:
Sheets("2.1. ").Select
Application.Goto Reference:="Totals"
Application.Run "'ET Utilities.xls'!xtractFromStd"
Selection.CurrentRegion.Select
Selection.Cut
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("I:\I:\ET\Report Template.dot")
With wrdDoc
Dim BmkNm As String
BmkNm = "S1"
End With

The crunch seems to be in wrdApp As Word.Application.

I'm sure it's very basic to you guys but any clues gratefully received by a
raw beginner.
Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Macro copying an array and pasting to a Word bookmark

Helmut Grüss from Lincolnshire.
Thanks for your response I have been away since you posted but I'll try this
tomorrow.
Thanks again
Jimbob

"Helmut Weber" wrote:

Hi Jimbob,

apart form other issues,
which will be addressed in the next question, IMHO,

Dim wrdApp As Word.Application


alone is not sufficient.

There has to be 'getobject' or 'createobject' in addition,
like for an already running instance of Word:

Dim wrdApp As Word.Application
set wrdApp = getobject(, "Word.Application")

With wrdDoc
Dim BmkNm As String
BmkNm = "S1"
End With


Doesn't affect Word at all.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Macro copying an array and pasting to a Word bookmark

Grüss from Lincolnshire again.
Helmut, that works a treat and my data is inserted. Unfortunately now it
falls over later, as I want to do some action on the matrix inserted but the
cursor is still marking the position in the Word document where it was
opened. I've tried GoTo Bookmark again but without success.
Any clues?

"Helmut Weber" wrote:

Hi Jimbob,

apart form other issues,
which will be addressed in the next question, IMHO,

Dim wrdApp As Word.Application


alone is not sufficient.

There has to be 'getobject' or 'createobject' in addition,
like for an already running instance of Word:

Dim wrdApp As Word.Application
set wrdApp = getobject(, "Word.Application")

With wrdDoc
Dim BmkNm As String
BmkNm = "S1"
End With


Doesn't affect Word at all.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

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
Copying a doc from Excel and pasting it into Word. KC New Users to Excel 2 March 14th 09 08:39 PM
Copying Cell data and pasting into word document? Simon Lloyd[_759_] Excel Programming 4 June 7th 06 10:41 AM
copying from word and pasting into excel nims[_4_] Excel Programming 1 August 24th 05 08:24 PM
Excel - Word: Problems copying/pasting shapes Nick Hebb Excel Programming 1 June 17th 05 09:55 PM
Need help pasting usedrange in word bookmark nickadeemus2002[_2_] Excel Programming 0 May 25th 04 04:08 PM


All times are GMT +1. The time now is 02:05 AM.

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"