Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / April 2008

Tip: Looking for answers? Try searching our database.

Opening and Coping Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
moflaher@justice.gc.ca - 28 Apr 2008 15:52 GMT
Hello,

I am trying to get information from an excel doc that is closed, copy
it, and paste it into the excel doc that i am working with.  This is
what i have and it seems to work until i hit the final step when i get
an error message saying "Object doesn't support this porperty or
method".  I have used this method of pasting before and never ran into
problems.

Any help would be much appreciated!

Sub CreateMaster()

Dim wkbCurrent As Workbook
Set wrbcurrent = ActiveWorkbook

 Workbooks.Open "sourcefile.xls"
 Worksheets("sheet2").Range("A1:J3").Select
 Selection.Copy
 ActiveWorkbook.Close SaveChanges:=False

 wrbcurrent.Activate

 Range("A1").Select
 Selection.Paste

End Sub
Earl Kiosterud - 28 Apr 2008 16:12 GMT
Try
ActiveSheet.Paste

I hope that's not your real email address.  The spambots will pick it up and you'll
eventually have to retire it.

Signature

Regards from Virginia Beach,

Earl Kiosterud
www.smokeylake.com
-----------------------------------------------------------------------

> Hello,
>
[quoted text clipped - 23 lines]
>
> End Sub
moflaher@justice.gc.ca - 28 Apr 2008 16:22 GMT
> Try
> ActiveSheet.Paste
[quoted text clipped - 39 lines]
>
> - Show quoted text -

Thanks that worked
GB - 28 Apr 2008 21:55 GMT
Isn't the problem just because of a typo?  wkbCurrent   vs  wrbcurrent

> > Dim wkbCurrent As Workbook
> > Set wrbcurrent = ActiveWorkbook
> > wrbcurrent.Activate

On Apr 28, 11:12 am, "Earl Kiosterud" <some...@nowhere.com> wrote:
> Try
> ActiveSheet.Paste
[quoted text clipped - 41 lines]
>
> - Show quoted text -

Thanks that worked
Earl Kiosterud - 28 Apr 2008 23:33 GMT
GB,

That's a separate problem.  With Option Explicit, the line "Set wrbcurrent = ActiveWorkbook"
would fail because wrbcurrent had never been dimmed (because of the typo).  But without it,
that line would create a workbook object that would be the active workbook.

Option Explicit is there for just these kinds of problems.  Not using it is like driving 100
MPH on the local interstate, and declaring it a safe thing to do because you did it once and
didn't have a wreck.  Some people think like that! :)
Signature

Regards from Virginia Beach,

Earl Kiosterud
www.smokeylake.com

If life deals you lemons, make lemonade; if it deals you tomatoes,
make Bloody Marys.

-----------------------------------------------------------------------

> Isn't the problem just because of a typo?  wkbCurrent   vs  wrbcurrent
>
[quoted text clipped - 49 lines]
>
> Thanks that worked
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.