Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
J J is offline
external usenet poster
 
Posts: 1
Default Macro-Text from word doc paste to excel empty row

Hi all!
I think that I am very close to the answer on this question so any
assistance you could give would be greatly appreciated!
I am calling a macro from word to format a page of text then copy and
open an excel doc paste it to the first *empty* row in this
spreadsheet.
So far I have:

[more code above...]
'Opens an Excel worksheet located in the default Documents folder


strXLPath = "C:\Fill_the_Bank_MasterList.xls"

Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Workbooks.Open (strXLPath)
Set objExcelBook = objExcelApp.ActiveWorkbook
Set objExcelSheets = objExcelBook.Worksheets
Set objExcelSheet = objExcelBook.Sheets(1)
objExcelSheet.Activate
objExcelApp.Application.Visible = True

'Paste clipboard into first empty row
'

objExcelSheet.Range("ListTop").Select
objExcelSheet.Selection.End(xlDown).Select <--- Error 438 here
objExcelSheet.ActiveCell.Offset(1, 0).PasteSpecial


End Sub

I get an error 438 on this (obj or property not supported on the line
as indicated. I can paste these lines into excel and run the macro
from inside excel, but when I run from word, I get the error. Should I
set this before I run in word?

Thanks again!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Macro-Text from word doc paste to excel empty row

I think you have a couple of problems. Selection belongs to a window or the
application--not the worksheet. Similarly with Activecell.

And unless you have a reference to excel in your word project, it won't know
what xlDown means. (And if you did have a reference to excel, you wouldn't have
used createobject????).

objExcelApp.Selection.End(-4121).Select
objExcelApp.ActiveCell.Offset(1, 0).PasteSpecial

A quick and dirty way to find excel's constants is to open excel, got to the VBE
and hit ctrl-G to see the immediate window.

then type:
?xldown
(? is old basic for print)

The immediate window showed this:
-4121

(You could also open the object browser and see lots of excel's constants all at
once.)


J wrote:

Hi all!
I think that I am very close to the answer on this question so any
assistance you could give would be greatly appreciated!
I am calling a macro from word to format a page of text then copy and
open an excel doc paste it to the first *empty* row in this
spreadsheet.
So far I have:

[more code above...]
'Opens an Excel worksheet located in the default Documents folder

strXLPath = "C:\Fill_the_Bank_MasterList.xls"

Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Workbooks.Open (strXLPath)
Set objExcelBook = objExcelApp.ActiveWorkbook
Set objExcelSheets = objExcelBook.Worksheets
Set objExcelSheet = objExcelBook.Sheets(1)
objExcelSheet.Activate
objExcelApp.Application.Visible = True

'Paste clipboard into first empty row
'

objExcelSheet.Range("ListTop").Select
objExcelSheet.Selection.End(xlDown).Select <--- Error 438 here
objExcelSheet.ActiveCell.Offset(1, 0).PasteSpecial


End Sub

I get an error 438 on this (obj or property not supported on the line
as indicated. I can paste these lines into excel and run the macro
from inside excel, but when I run from word, I get the error. Should I
set this before I run in word?

Thanks again!


--

Dave Peterson

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
how to cut text out of excel & paste into word? mhw Excel Worksheet Functions 1 January 14th 09 12:50 AM
Special Paste to Next empty row if new data and mark copied Macro Madhart Excel Discussion (Misc queries) 0 August 29th 08 10:39 AM
How to set macro to Paste Special Value to next empty column [email protected] Excel Worksheet Functions 9 May 5th 08 11:57 PM
Using a macro to paste into first empty row in a new worksheet Bruce64 Excel Worksheet Functions 3 January 13th 08 08:18 PM
missing text when using paste special from word to excel scottymoore14 Excel Discussion (Misc queries) 2 December 21st 06 05:09 PM


All times are GMT +1. The time now is 11:55 PM.

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

About Us

"It's about Microsoft Excel"