Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Error I cannot figure out

The following code runs well if inventory xls is not open

(...)
Application.DisplayAlerts=True
Columns("A:C").Copy
Workbooks.Open ("c:\documents and settings\antonio\my
documents\inventory.xls")
Worksheets("rent").Activate

Columns("D:F").Select
ActiveSheet.Paste

However, if inventory.xls is already open, when I run the above I get error
at the last line: "Paste failed"


The strange thing is that when running line 3 it does not show the dialog
that inventory.xls is already open.

It seems that it has something to do with reopening inventory.xls but I
cannot figure out where the problem is.

If I have inventory.xls open and I do not reopen it with VBA it works fine.

Thanks,

Antonio

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error I cannot figure out

Sometimes just rearranging the order of the copy and open will work wonders:

dim rngtocopy as range
set rngtocopy = columns("a:c")

Workbooks.Open ("c:\documents and settings\antonio\my documents\inventory.xls")
Worksheets("rent").Activate
Columns("D:F").Select

rngtocopy.copy
ActiveSheet.Paste

=======
Or maybe...

dim rngtocopy as range
set rngtocopy = columns("a:c")

Workbooks.Open ("c:\documents and settings\antonio\my documents\inventory.xls")
rngtocopy.copy _
destination:=worksheets("rent").range("D1")



Antonio wrote:

The following code runs well if inventory xls is not open

(...)
Application.DisplayAlerts=True
Columns("A:C").Copy
Workbooks.Open ("c:\documents and settings\antonio\my
documents\inventory.xls")
Worksheets("rent").Activate

Columns("D:F").Select
ActiveSheet.Paste

However, if inventory.xls is already open, when I run the above I get error
at the last line: "Paste failed"

The strange thing is that when running line 3 it does not show the dialog
that inventory.xls is already open.

It seems that it has something to do with reopening inventory.xls but I
cannot figure out where the problem is.

If I have inventory.xls open and I do not reopen it with VBA it works fine.

Thanks,

Antonio


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Error I cannot figure out

Hi Dave,

I have tried the second alternative and it works. Many thanks.

However, I am unhappy about this. It seems to be a bug and I don't like the
feeling of not working with a robust application.

Thanks,

Antonio

"Dave Peterson" wrote:

Sometimes just rearranging the order of the copy and open will work wonders:

dim rngtocopy as range
set rngtocopy = columns("a:c")

Workbooks.Open ("c:\documents and settings\antonio\my documents\inventory.xls")
Worksheets("rent").Activate
Columns("D:F").Select

rngtocopy.copy
ActiveSheet.Paste

=======
Or maybe...

dim rngtocopy as range
set rngtocopy = columns("a:c")

Workbooks.Open ("c:\documents and settings\antonio\my documents\inventory.xls")
rngtocopy.copy _
destination:=worksheets("rent").range("D1")



Antonio wrote:

The following code runs well if inventory xls is not open

(...)
Application.DisplayAlerts=True
Columns("A:C").Copy
Workbooks.Open ("c:\documents and settings\antonio\my
documents\inventory.xls")
Worksheets("rent").Activate

Columns("D:F").Select
ActiveSheet.Paste

However, if inventory.xls is already open, when I run the above I get error
at the last line: "Paste failed"

The strange thing is that when running line 3 it does not show the dialog
that inventory.xls is already open.

It seems that it has something to do with reopening inventory.xls but I
cannot figure out where the problem is.

If I have inventory.xls open and I do not reopen it with VBA it works fine.

Thanks,

Antonio


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error I cannot figure out

There are lots of things that lose the clipboard when you're working in excel
manually.

I'm not sure I would classify it as a bug, but it is something that you (as a
programmer) have to be aware of.

Antonio wrote:

Hi Dave,

I have tried the second alternative and it works. Many thanks.

However, I am unhappy about this. It seems to be a bug and I don't like the
feeling of not working with a robust application.

Thanks,

Antonio

"Dave Peterson" wrote:

Sometimes just rearranging the order of the copy and open will work wonders:

dim rngtocopy as range
set rngtocopy = columns("a:c")

Workbooks.Open ("c:\documents and settings\antonio\my documents\inventory.xls")
Worksheets("rent").Activate
Columns("D:F").Select

rngtocopy.copy
ActiveSheet.Paste

=======
Or maybe...

dim rngtocopy as range
set rngtocopy = columns("a:c")

Workbooks.Open ("c:\documents and settings\antonio\my documents\inventory.xls")
rngtocopy.copy _
destination:=worksheets("rent").range("D1")



Antonio wrote:

The following code runs well if inventory xls is not open

(...)
Application.DisplayAlerts=True
Columns("A:C").Copy
Workbooks.Open ("c:\documents and settings\antonio\my
documents\inventory.xls")
Worksheets("rent").Activate

Columns("D:F").Select
ActiveSheet.Paste

However, if inventory.xls is already open, when I run the above I get error
at the last line: "Paste failed"

The strange thing is that when running line 3 it does not show the dialog
that inventory.xls is already open.

It seems that it has something to do with reopening inventory.xls but I
cannot figure out where the problem is.

If I have inventory.xls open and I do not reopen it with VBA it works fine.

Thanks,

Antonio


--

Dave Peterson


--

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 'BLINK' A FIGURE INSTEAD OFF BOLDING THE FIGURE Nad.Engoor Excel Worksheet Functions 3 December 30th 08 03:04 PM
wierd error I cannot figure out Antonio Excel Programming 3 May 11th 06 09:38 PM
Help, I can't figure this out sharpie23 Excel Programming 1 October 28th 05 03:10 PM
error 400, i cant figure this out.. Michael A Excel Programming 4 March 6th 05 11:18 PM
Some Error that I can't figure out. Mcobra41 Excel Discussion (Misc queries) 1 February 28th 05 11:42 PM


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

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"