B
Bon
Hello all
I created a function which has two things to do. First, it is used to
copy a range excel value (e.g. A18). 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.Paste <-- 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
I created a function which has two things to do. First, it is used to
copy a range excel value (e.g. A18). 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.Paste <-- 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