Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Marissa
 
Posts: n/a
Default allow template user to insert picture

I'm creating a form which I will save as a protected template. How do I allow
users to insert their own logo in a designated area? Is this possible? I
tried using the "image" control box field but I'm not sure if this is what it
is intended for.

Thanks
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

I think I'd use a macro that asked for the logo, unprotected the worksheet,
added the logo and then reprotected the worksheet.

Kind of...

Option Explicit
Sub testme()
Dim myPictName As Variant
Dim myPict As Picture
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

myPictName _
= Application.GetOpenFilename("Picture files, *.bmp;*.jpg;*.gif")
If myPictName = False Then
MsgBox "try later!"
Exit Sub
End If

With wks
.Unprotect Password:="hi"
With .Range("a1:B9")
Set myPict = .Parent.Pictures.Insert(myPictName)
myPict.Top = .Top
myPict.Left = .Left
myPict.Width = .Width
myPict.Height = .Height
End With
.Protect Password:="hi"
End With

End Sub

And you could completely control where the logo went.


Marissa wrote:

I'm creating a form which I will save as a protected template. How do I allow
users to insert their own logo in a designated area? Is this possible? I
tried using the "image" control box field but I'm not sure if this is what it
is intended for.

Thanks


--

Dave Peterson
  #3   Report Post  
Marissa
 
Posts: n/a
Default

Dave,

That works great! Now, since I don't know ahead of time how big or small the
logos could be, if I tell the macro to fit it within a certain range, it
could get stretched out of proportion. I tried just referencing one cell as
the starting point, but instead it squeezed or stretched the picture into
that one cell.

"Dave Peterson" wrote:

I think I'd use a macro that asked for the logo, unprotected the worksheet,
added the logo and then reprotected the worksheet.

Kind of...

Option Explicit
Sub testme()
Dim myPictName As Variant
Dim myPict As Picture
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

myPictName _
= Application.GetOpenFilename("Picture files, *.bmp;*.jpg;*.gif")
If myPictName = False Then
MsgBox "try later!"
Exit Sub
End If

With wks
.Unprotect Password:="hi"
With .Range("a1:B9")
Set myPict = .Parent.Pictures.Insert(myPictName)
myPict.Top = .Top
myPict.Left = .Left
myPict.Width = .Width
myPict.Height = .Height
End With
.Protect Password:="hi"
End With

End Sub

And you could completely control where the logo went.


Marissa wrote:

I'm creating a form which I will save as a protected template. How do I allow
users to insert their own logo in a designated area? Is this possible? I
tried using the "image" control box field but I'm not sure if this is what it
is intended for.

Thanks


--

Dave Peterson

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

Try commenting out these lines:
myPict.Width = .Width
myPict.Height = .Height

The logos will be their "natural" size.


Marissa wrote:

Dave,

That works great! Now, since I don't know ahead of time how big or small the
logos could be, if I tell the macro to fit it within a certain range, it
could get stretched out of proportion. I tried just referencing one cell as
the starting point, but instead it squeezed or stretched the picture into
that one cell.

"Dave Peterson" wrote:

I think I'd use a macro that asked for the logo, unprotected the worksheet,
added the logo and then reprotected the worksheet.

Kind of...

Option Explicit
Sub testme()
Dim myPictName As Variant
Dim myPict As Picture
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

myPictName _
= Application.GetOpenFilename("Picture files, *.bmp;*.jpg;*.gif")
If myPictName = False Then
MsgBox "try later!"
Exit Sub
End If

With wks
.Unprotect Password:="hi"
With .Range("a1:B9")
Set myPict = .Parent.Pictures.Insert(myPictName)
myPict.Top = .Top
myPict.Left = .Left
myPict.Width = .Width
myPict.Height = .Height
End With
.Protect Password:="hi"
End With

End Sub

And you could completely control where the logo went.


Marissa wrote:

I'm creating a form which I will save as a protected template. How do I allow
users to insert their own logo in a designated area? Is this possible? I
tried using the "image" control box field but I'm not sure if this is what it
is intended for.

Thanks


--

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 insert a picture in the Footer (not the Header) in Excel 20 jmon Excel Worksheet Functions 2 March 17th 05 05:59 AM
insert picture BillGwyer Excel Discussion (Misc queries) 1 March 4th 05 06:37 PM
How do I insert a clip art picture into a text box in word 2003 Lindas Excel Discussion (Misc queries) 2 January 26th 05 04:47 PM
Challenging Charting C TO Charts and Charting in Excel 0 January 17th 05 06:57 PM
how can I insert a picture conditional on another cell Boyd Excel Worksheet Functions 2 December 15th 04 08:25 PM


All times are GMT +1. The time now is 11:41 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"