PC Review


Reply
Thread Tools Rate Thread

Copy image to tabs

 
 
=?Utf-8?B?RGFuIEtlbGx5?=
Guest
Posts: n/a
 
      15th Mar 2007
I'm having a problem copying an image embedded on a template into a second
workbook. The image "Picture 1" is on a template called "Test.xlt". It is
copied to a tab called "Blank" in the main workbook and then onto all
subsequent tabs.

The first part of the following code works - copying the image from the
template to blank and repositioning the image. The problem occurs after
copying the image from Blank to the next tab. Each tab is activated in order
and unprotected prior to this call:

If ActiveSheet.Name = "Blank" Then
' This all works
Workbooks.Open FileName:="Test.xlt"
ActiveSheet.Shapes("Picture 1").Select
Selection.Copy
ActiveWindow.Close
Sheets("Blank").Activate
ActiveSheet.Unprotect
ActiveSheet.Paste
Else
' It appears that I can copy "Picture 1"
Sheets("Blank").Unprotect
Sheets("Blank").Shapes("Picture 1").Select
Selection.Copy
' Paste to current tab appears to work
ActiveSheet.Paste
End If
** Problems occur here on second pass**
Selection.ShapeRange.Top = 29.25
Selection.ShapeRange.Left = 323.25
Selection.ShapeRange.Height = 44.25
Selection.ShapeRange.LockAspectRatio = msoTrue

Any suggestions ?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      15th Mar 2007
You should be getting an error here:
Sheets("Blank").Shapes("Picture 1").Select

that code doesn't execute unless Blank is not the activesheet. You can't
select the Picture unless Blank is the activesheet. So I believe you
misinterpret where the error occurs.

If ActiveSheet.Name = "Blank" Then
' This all works
Workbooks.Open FileName:="Test.xlt"
ActiveSheet.Shapes("Picture 1").Select
Selection.Copy
ActiveWindow.Close
Sheets("Blank").Activate
ActiveSheet.Unprotect
ActiveSheet.Paste
Else
' It appears that I can copy "Picture 1"
Sheets("Blank").Unprotect
Sheets("Blank").Shapes("Picture 1").Copy
' Paste to current tab appears to work
ActiveSheet.Paste
End If
** Problems occur here on second pass**
Selection.ShapeRange.Top = 29.25
Selection.ShapeRange.Left = 323.25
Selection.ShapeRange.Height = 44.25
Selection.ShapeRange.LockAspectRatio = msoTrue

--
Regards,
Tom Ogilvy


"Dan Kelly" wrote:

> I'm having a problem copying an image embedded on a template into a second
> workbook. The image "Picture 1" is on a template called "Test.xlt". It is
> copied to a tab called "Blank" in the main workbook and then onto all
> subsequent tabs.
>
> The first part of the following code works - copying the image from the
> template to blank and repositioning the image. The problem occurs after
> copying the image from Blank to the next tab. Each tab is activated in order
> and unprotected prior to this call:
>
> If ActiveSheet.Name = "Blank" Then
> ' This all works
> Workbooks.Open FileName:="Test.xlt"
> ActiveSheet.Shapes("Picture 1").Select
> Selection.Copy
> ActiveWindow.Close
> Sheets("Blank").Activate
> ActiveSheet.Unprotect
> ActiveSheet.Paste
> Else
> ' It appears that I can copy "Picture 1"
> Sheets("Blank").Unprotect
> Sheets("Blank").Shapes("Picture 1").Select
> Selection.Copy
> ' Paste to current tab appears to work
> ActiveSheet.Paste
> End If
> ** Problems occur here on second pass**
> Selection.ShapeRange.Top = 29.25
> Selection.ShapeRange.Left = 323.25
> Selection.ShapeRange.Height = 44.25
> Selection.ShapeRange.LockAspectRatio = msoTrue
>
> Any suggestions ?

 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      15th Mar 2007
I got the code to work by adding a select here in the code

Sheets("Blank").Select
Sheets("Blank").Unprotect
Sheets("Blank").Shapes("Picture 1").Select

It wasn't pasting the picture on my sheet two until I added the select.
Then it did not give an error until the picture was moved.


"Dan Kelly" wrote:

> I'm having a problem copying an image embedded on a template into a second
> workbook. The image "Picture 1" is on a template called "Test.xlt". It is
> copied to a tab called "Blank" in the main workbook and then onto all
> subsequent tabs.
>
> The first part of the following code works - copying the image from the
> template to blank and repositioning the image. The problem occurs after
> copying the image from Blank to the next tab. Each tab is activated in order
> and unprotected prior to this call:
>
> If ActiveSheet.Name = "Blank" Then
> ' This all works
> Workbooks.Open FileName:="Test.xlt"
> ActiveSheet.Shapes("Picture 1").Select
> Selection.Copy
> ActiveWindow.Close
> Sheets("Blank").Activate
> ActiveSheet.Unprotect
> ActiveSheet.Paste
> Else
> ' It appears that I can copy "Picture 1"
> Sheets("Blank").Unprotect
> Sheets("Blank").Shapes("Picture 1").Select
> Selection.Copy
> ' Paste to current tab appears to work
> ActiveSheet.Paste
> End If
> ** Problems occur here on second pass**
> Selection.ShapeRange.Top = 29.25
> Selection.ShapeRange.Left = 323.25
> Selection.ShapeRange.Height = 44.25
> Selection.ShapeRange.LockAspectRatio = msoTrue
>
> Any suggestions ?

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      15th Mar 2007
Since Joel raised some doubt, I tested the code. The code I posted works
fine for me without further modification.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote:

> You should be getting an error here:
> Sheets("Blank").Shapes("Picture 1").Select
>
> that code doesn't execute unless Blank is not the activesheet. You can't
> select the Picture unless Blank is the activesheet. So I believe you
> misinterpret where the error occurs.
>
> If ActiveSheet.Name = "Blank" Then
> ' This all works
> Workbooks.Open FileName:="Test.xlt"
> ActiveSheet.Shapes("Picture 1").Select
> Selection.Copy
> ActiveWindow.Close
> Sheets("Blank").Activate
> ActiveSheet.Unprotect
> ActiveSheet.Paste
> Else
> ' It appears that I can copy "Picture 1"
> Sheets("Blank").Unprotect
> Sheets("Blank").Shapes("Picture 1").Copy
> ' Paste to current tab appears to work
> ActiveSheet.Paste
> End If
> ** Problems occur here on second pass**
> Selection.ShapeRange.Top = 29.25
> Selection.ShapeRange.Left = 323.25
> Selection.ShapeRange.Height = 44.25
> Selection.ShapeRange.LockAspectRatio = msoTrue
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Dan Kelly" wrote:
>
> > I'm having a problem copying an image embedded on a template into a second
> > workbook. The image "Picture 1" is on a template called "Test.xlt". It is
> > copied to a tab called "Blank" in the main workbook and then onto all
> > subsequent tabs.
> >
> > The first part of the following code works - copying the image from the
> > template to blank and repositioning the image. The problem occurs after
> > copying the image from Blank to the next tab. Each tab is activated in order
> > and unprotected prior to this call:
> >
> > If ActiveSheet.Name = "Blank" Then
> > ' This all works
> > Workbooks.Open FileName:="Test.xlt"
> > ActiveSheet.Shapes("Picture 1").Select
> > Selection.Copy
> > ActiveWindow.Close
> > Sheets("Blank").Activate
> > ActiveSheet.Unprotect
> > ActiveSheet.Paste
> > Else
> > ' It appears that I can copy "Picture 1"
> > Sheets("Blank").Unprotect
> > Sheets("Blank").Shapes("Picture 1").Select
> > Selection.Copy
> > ' Paste to current tab appears to work
> > ActiveSheet.Paste
> > End If
> > ** Problems occur here on second pass**
> > Selection.ShapeRange.Top = 29.25
> > Selection.ShapeRange.Left = 323.25
> > Selection.ShapeRange.Height = 44.25
> > Selection.ShapeRange.LockAspectRatio = msoTrue
> >
> > Any suggestions ?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy shape image into image control Luc Benninger Microsoft Excel Programming 3 21st Feb 2011 10:17 PM
Image on tabs in forms Dennis Wolf Microsoft Access Forms 0 22nd Dec 2007 11:28 AM
Background image with tabs =?Utf-8?B?UmljaCBTdG9uZQ==?= Microsoft Access Forms 5 29th Jun 2006 02:31 AM
printing multiple sheet tabs to image file =?Utf-8?B?MDQ5Mi1FeGFtaW5lcg==?= Microsoft Excel Misc 0 19th Oct 2005 10:43 PM
FP tabs taking on the background/desktop image =?Utf-8?B?RGF2ZQ==?= Microsoft Frontpage 4 7th Sep 2005 08:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:22 AM.