Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Programmatic addition of form elements relative to a cell

Is it possible to programmatically add a form element to a worksheet where
do you can something along the lines of specifying it's location relative to
a cell?
Thanks
Matt


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Programmatic addition of form elements relative to a cell

If you record a macro while you do it manually you get

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Check Box.1", Link:=False, _
DisplayAsIcon:=False, Left:=377.25, Top:=114.75, Width:=78, Height:=
_
18.75).Select


so you could do
lTop = Range("B9").top
lLeft = Range("B9").Left
lWidth = Range("B9").Width
lHeight = Range("B9").Height
ActiveSheet.OLEObjects.Add ClassType:="Forms.CheckBox.1", _
Link:=False, DisplayAsIcon:=False, _
Left:=lLeft, Top:=lTop, Width:=lWidth, Height:=lHeight

--
Regards,
Tom Ogilvy




"Matt Jensen" wrote in message
...
Is it possible to programmatically add a form element to a worksheet where
do you can something along the lines of specifying it's location relative

to
a cell?
Thanks
Matt




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Programmatic addition of form elements relative to a cell

Nice one! :-)
Thanks
matt

"Tom Ogilvy" wrote in message
...
If you record a macro while you do it manually you get

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Check Box.1", Link:=False,

_
DisplayAsIcon:=False, Left:=377.25, Top:=114.75, Width:=78,

Height:=
_
18.75).Select


so you could do
lTop = Range("B9").top
lLeft = Range("B9").Left
lWidth = Range("B9").Width
lHeight = Range("B9").Height
ActiveSheet.OLEObjects.Add ClassType:="Forms.CheckBox.1", _
Link:=False, DisplayAsIcon:=False, _
Left:=lLeft, Top:=lTop, Width:=lWidth, Height:=lHeight

--
Regards,
Tom Ogilvy




"Matt Jensen" wrote in message
...
Is it possible to programmatically add a form element to a worksheet

where
do you can something along the lines of specifying it's location

relative
to
a cell?
Thanks
Matt






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Programmatic addition of form elements relative to a cell

Tom
In reference to the code you kindly provided below, I'm wondering about the
DisplayAsIcon property as well as images in workbooks in general.
I've seen examples of putting images on forms programmatically by loading
them from a file location, however since my excel workbook/macro will not
always be in the one location this will not work.
Is there a way to embed images in a workbook and then access them and show
them where I like in my workbook?
Thanks
Matt

"Tom Ogilvy" wrote in message
...
If you record a macro while you do it manually you get

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Check Box.1", Link:=False,

_
DisplayAsIcon:=False, Left:=377.25, Top:=114.75, Width:=78,

Height:=
_
18.75).Select


so you could do
lTop = Range("B9").top
lLeft = Range("B9").Left
lWidth = Range("B9").Width
lHeight = Range("B9").Height
ActiveSheet.OLEObjects.Add ClassType:="Forms.CheckBox.1", _
Link:=False, DisplayAsIcon:=False, _
Left:=lLeft, Top:=lTop, Width:=lWidth, Height:=lHeight

--
Regards,
Tom Ogilvy




"Matt Jensen" wrote in message
...
Is it possible to programmatically add a form element to a worksheet

where
do you can something along the lines of specifying it's location

relative
to
a cell?
Thanks
Matt






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Programmatic addition of form elements relative to a cell

In the menu, insert=Picture select from file and insert your picture.

Do this on a sheet you will use for storage of the images (and will probably
hide).

Then in code you can copy and paste it to where you want.

Sub copypicture()
Worksheets("Sheet13").Shapes("Picture 1").Copy
Worksheets("Sheet2").Activate
Range("B9").Activate
ActiveSheet.Paste
End Sub

Sheet13 held the image and the sheet was hidden.

--
Regards,
Tom Ogilvy



"Matt Jensen" wrote in message
...
Tom
In reference to the code you kindly provided below, I'm wondering about

the
DisplayAsIcon property as well as images in workbooks in general.
I've seen examples of putting images on forms programmatically by loading
them from a file location, however since my excel workbook/macro will not
always be in the one location this will not work.
Is there a way to embed images in a workbook and then access them and show
them where I like in my workbook?
Thanks
Matt

"Tom Ogilvy" wrote in message
...
If you record a macro while you do it manually you get

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Check Box.1",

Link:=False,
_
DisplayAsIcon:=False, Left:=377.25, Top:=114.75, Width:=78,

Height:=
_
18.75).Select


so you could do
lTop = Range("B9").top
lLeft = Range("B9").Left
lWidth = Range("B9").Width
lHeight = Range("B9").Height
ActiveSheet.OLEObjects.Add ClassType:="Forms.CheckBox.1", _
Link:=False, DisplayAsIcon:=False, _
Left:=lLeft, Top:=lTop, Width:=lWidth, Height:=lHeight

--
Regards,
Tom Ogilvy




"Matt Jensen" wrote in message
...
Is it possible to programmatically add a form element to a worksheet

where
do you can something along the lines of specifying it's location

relative
to
a cell?
Thanks
Matt










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Programmatic addition of form elements relative to a cell

Excellent - thanks Tom
Cheers
Matt

"Tom Ogilvy" wrote in message
...
In the menu, insert=Picture select from file and insert your picture.

Do this on a sheet you will use for storage of the images (and will

probably
hide).

Then in code you can copy and paste it to where you want.

Sub copypicture()
Worksheets("Sheet13").Shapes("Picture 1").Copy
Worksheets("Sheet2").Activate
Range("B9").Activate
ActiveSheet.Paste
End Sub

Sheet13 held the image and the sheet was hidden.

--
Regards,
Tom Ogilvy



"Matt Jensen" wrote in message
...
Tom
In reference to the code you kindly provided below, I'm wondering about

the
DisplayAsIcon property as well as images in workbooks in general.
I've seen examples of putting images on forms programmatically by

loading
them from a file location, however since my excel workbook/macro will

not
always be in the one location this will not work.
Is there a way to embed images in a workbook and then access them and

show
them where I like in my workbook?
Thanks
Matt

"Tom Ogilvy" wrote in message
...
If you record a macro while you do it manually you get

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Check Box.1",

Link:=False,
_
DisplayAsIcon:=False, Left:=377.25, Top:=114.75, Width:=78,

Height:=
_
18.75).Select


so you could do
lTop = Range("B9").top
lLeft = Range("B9").Left
lWidth = Range("B9").Width
lHeight = Range("B9").Height
ActiveSheet.OLEObjects.Add ClassType:="Forms.CheckBox.1", _
Link:=False, DisplayAsIcon:=False, _
Left:=lLeft, Top:=lTop, Width:=lWidth, Height:=lHeight

--
Regards,
Tom Ogilvy




"Matt Jensen" wrote in message
...
Is it possible to programmatically add a form element to a worksheet

where
do you can something along the lines of specifying it's location

relative
to
a cell?
Thanks
Matt










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
Programmatic Hiding [email protected] Excel Discussion (Misc queries) 2 September 29th 07 01:13 PM
changing from relative to absolute cell reference in multiple form JAaron Excel Worksheet Functions 1 May 22nd 06 08:06 AM
input form and addition alexanderd Excel Discussion (Misc queries) 3 July 19th 05 09:59 PM
Pivot table with form elements Matt Jensen Excel Programming 3 December 9th 04 09:04 AM
Assign macros to dynamically created form elements Joepy Excel Programming 4 March 3rd 04 09:03 PM


All times are GMT +1. The time now is 08:45 AM.

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"