Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bon Bon is offline
external usenet poster
 
Posts: 23
Default How to copy cells excel data and paste them under MS Word bookmark

Hello all

I created a function which has two things to do. First, it is used to
copy a range excel value (e.g. A1:D8). Another function, it is used to
copy a cell value (e.g. F10) on the same excel worksheet and return to
the value to the caller function. The range of excel value can't be
pasted under MS Word bookmark. But, the range of cxcel value can't be
pasted under the bookmark. Sometime, MS Word bookmark is pasted by the
function code. How can I solve the problem?

My code prototype:

Function ModuleInAccess()

Dim xlApp As Excel.Application
Dim xlWorkbook As Excel.Workbook
Dim xlWorksheet As Excel.Worksheet
Dim strReturnValue

Set xlApp = CreateObject("Excel.Application")
Set xlWorksheet = xlApp.Workbooks.Open(Filename:=ExcelWorkbookName)
xlWorksheet("Sheet1").Select
....
strReturnValue = xlWorksheet.Range("F10").value

....
With xlWorksheet("Sheet1").Range(Cells(1,1),Cells(8,4))
..Select
..Copy
End With

MSAccessFunction = strReturnValue
End Function

Function CallerModuleInAccess()
Dim wdApp As Word.Application
Dim strGetReturnValue As String

Set wdApp = CreateObject("Word.Application")

With wdApp
strGetReturnValue = ModuleInAccess
..ActiveDocument.Bookmarks("bookmark1").Range.Text = strGetReturnValue
..ActiveDocument.Bookmarks("bookmark2").Range.Past e <-- Paste the copied
range of cells value
End With
End Function

I don't know why it can copy and paste a cell value, but the range of
cells value can't be pasted. Could anyone give me some suggestion on
solving this problem?

Thanks

Cheers
Bon

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
copy and paste range of cells excluding hidden data in excel Steve22055 Excel Discussion (Misc queries) 3 October 23rd 08 01:57 PM
How do I copy data in Excel cells and paste in Word w/o cell borde Nsimm13 Excel Discussion (Misc queries) 1 September 1st 06 03:35 PM
hyperlink from Excel to a Word bookmark Bertie Excel Discussion (Misc queries) 2 May 16th 06 07:51 PM
How do I copy selected cells in excel and paste into word table REVA Excel Programming 2 January 4th 06 09:43 PM
IsEmpty and bookmark help with excel 97 and word 97 JMCN Excel Programming 0 July 15th 04 05:31 PM


All times are GMT +1. The time now is 11:11 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"