Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Macros not appearing in the Tools Macro Macros list

Hello there,

I copied code the following 4 procedures from a website into an xl code
module,
as the instruction read.

Its intention is to create invisible reactangles around a cell,
which in turn can fire a macro when the "cell" is clicked.
Thereafter, the rectangle shall be deleted again..

However, only 2 of those procedures (SetRectangle and Test) appear in the
macros list, whatever I try.

What may go wrong ?



'---------------------------------------------------------------------------
-----
Private Const pcfTransparency As Double = 1
'---------------------------------------------------------------------------
-----
Sub AddRectangle(r As Excel.Range, tOnAction As String)
Dim rect As Shape

Call DelRectangle(r)

'Create the shape
With r.Cells(1, 1)
Set rect = .Parent.Shapes.AddShape(1, .Left, .Top, .Width, .Height)
'Make it invisible
With rect
.Fill.Transparency = pcfTransparency
.Line.Transparency = pcfTransparency
.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column
If tOnAction < vbNullString Then
.OnAction = tOnAction
End If
End With
End With
End Sub
'---------------------------------------------------------------------------
-----
Sub DelRectangle(r As Excel.Range)
Dim rect As Shape

'Delete the shape
With r
For Each rect In .Parent.Shapes
If rect.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column Then
rect.Delete
Exit Sub
End If
Next rect
End With
End Sub
'---------------------------------------------------------------------------
-----
Public Sub SetRectangle()
' Create a test environment
Call AddRectangle(ActiveCell, "Test")
End Sub
'---------------------------------------------------------------------------
-----
Public Sub Test()
' Display a MsgBox
Call MsgBox("It's only a test")
End Sub

<<<<<<<<<<<<<<<<<<<<<<<<<


What I want is automatically getting rid of the freshly created rectangles
as soon as the
"test"-procedure runs.

Your help is greatly appreciated.

Kind regards,


H.G. Lamy


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Macros not appearing in the Tools Macro Macros list

Hi HG

Macros that require variables passed to them can not be run alone -since
nothing is passed then. That's why they don't appear.

Sub testPass()
Call TestReceive("Yo da man")
End Sub

Sub TestReceive(Msg As String)
MsgBox Msg, , "TestReceive says:"
End Sub

The TestReceive needs variable input, and that is what is put between its
parentheses.

Call the Delete code from immediately after the msgbox in your code to get
rid of it. Note also that ActiveCell may change before the click, so I
suggest you save the creation range and use that for deletion. Adjusted
code:

Option Explicit

Private Const pcfTransparency As Double = 1
Dim RectRange As Range 'NEW
'---------------------------------------------------------------------------

Sub AddRectangle(r As Excel.Range, tOnAction As String)
Dim rect As Shape

Call DelRectangle(r)

'Create the shape
With r.Cells(1, 1)
Set rect = .Parent.Shapes.AddShape(1, .Left, .Top, .Width, .Height)
'Make it invisible
With rect
.Fill.Transparency = pcfTransparency
.Line.Transparency = pcfTransparency
.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column
If tOnAction < vbNullString Then
.OnAction = tOnAction
End If
End With
End With
End Sub
'---------------------------------------------------------------------------

Sub DelRectangle(r As Excel.Range)
Dim rect As Shape

'Delete the shape
With r
For Each rect In .Parent.Shapes
If rect.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column Then
rect.Delete
Exit Sub
End If
Next rect
End With
End Sub
'---------------------------------------------------------------------------

Public Sub SetRectangle()
' Create a test environment
Set RectRange = ActiveCell 'NEW
Call AddRectangle(RectRange, "Test") 'MODIFIED
End Sub

Public Sub Test()
' Display a MsgBox
Call MsgBox("It's only a test")
Call DelRectangle(RectRange)'NEW
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please

"hglamy" skrev i melding
...
Hello there,

I copied code the following 4 procedures from a website into an xl code
module,
as the instruction read.

Its intention is to create invisible reactangles around a cell,
which in turn can fire a macro when the "cell" is clicked.
Thereafter, the rectangle shall be deleted again..

However, only 2 of those procedures (SetRectangle and Test) appear in the
macros list, whatever I try.

What may go wrong ?




'---------------------------------------------------------------------------
-----
Private Const pcfTransparency As Double = 1

'---------------------------------------------------------------------------
-----
Sub AddRectangle(r As Excel.Range, tOnAction As String)
Dim rect As Shape

Call DelRectangle(r)

'Create the shape
With r.Cells(1, 1)
Set rect = .Parent.Shapes.AddShape(1, .Left, .Top, .Width, .Height)
'Make it invisible
With rect
.Fill.Transparency = pcfTransparency
.Line.Transparency = pcfTransparency
.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column
If tOnAction < vbNullString Then
.OnAction = tOnAction
End If
End With
End With
End Sub

'---------------------------------------------------------------------------
-----
Sub DelRectangle(r As Excel.Range)
Dim rect As Shape

'Delete the shape
With r
For Each rect In .Parent.Shapes
If rect.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column Then
rect.Delete
Exit Sub
End If
Next rect
End With
End Sub

'---------------------------------------------------------------------------
-----
Public Sub SetRectangle()
' Create a test environment
Call AddRectangle(ActiveCell, "Test")
End Sub

'---------------------------------------------------------------------------
-----
Public Sub Test()
' Display a MsgBox
Call MsgBox("It's only a test")
End Sub

<<<<<<<<<<<<<<<<<<<<<<<<<


What I want is automatically getting rid of the freshly created rectangles
as soon as the
"test"-procedure runs.

Your help is greatly appreciated.

Kind regards,


H.G. Lamy




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Macros not appearing in the Tools Macro Macros list

Thank you very much for this fast - and well working - reply / solution,
Harald !

Kind regards,

H.G. Lamy


"hglamy" schrieb im Newsbeitrag
...
Hello there,

I copied code the following 4 procedures from a website into an xl code
module,
as the instruction read.

Its intention is to create invisible reactangles around a cell,
which in turn can fire a macro when the "cell" is clicked.
Thereafter, the rectangle shall be deleted again..

However, only 2 of those procedures (SetRectangle and Test) appear in the
macros list, whatever I try.

What may go wrong ?




'---------------------------------------------------------------------------
-----
Private Const pcfTransparency As Double = 1

'---------------------------------------------------------------------------
-----
Sub AddRectangle(r As Excel.Range, tOnAction As String)
Dim rect As Shape

Call DelRectangle(r)

'Create the shape
With r.Cells(1, 1)
Set rect = .Parent.Shapes.AddShape(1, .Left, .Top, .Width, .Height)
'Make it invisible
With rect
.Fill.Transparency = pcfTransparency
.Line.Transparency = pcfTransparency
.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column
If tOnAction < vbNullString Then
.OnAction = tOnAction
End If
End With
End With
End Sub

'---------------------------------------------------------------------------
-----
Sub DelRectangle(r As Excel.Range)
Dim rect As Shape

'Delete the shape
With r
For Each rect In .Parent.Shapes
If rect.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column Then
rect.Delete
Exit Sub
End If
Next rect
End With
End Sub

'---------------------------------------------------------------------------
-----
Public Sub SetRectangle()
' Create a test environment
Call AddRectangle(ActiveCell, "Test")
End Sub

'---------------------------------------------------------------------------
-----
Public Sub Test()
' Display a MsgBox
Call MsgBox("It's only a test")
End Sub

<<<<<<<<<<<<<<<<<<<<<<<<<


What I want is automatically getting rid of the freshly created rectangles
as soon as the
"test"-procedure runs.

Your help is greatly appreciated.

Kind regards,


H.G. Lamy




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macros not appearing in the Tools Macro Macros list

Just don't call SetRectangle twice.

--
Regards,
Tom Ogilvy

"hglamy" wrote in message
...
Thank you very much for this fast - and well working - reply / solution,
Harald !

Kind regards,

H.G. Lamy


"hglamy" schrieb im Newsbeitrag
...
Hello there,

I copied code the following 4 procedures from a website into an xl code
module,
as the instruction read.

Its intention is to create invisible reactangles around a cell,
which in turn can fire a macro when the "cell" is clicked.
Thereafter, the rectangle shall be deleted again..

However, only 2 of those procedures (SetRectangle and Test) appear in

the
macros list, whatever I try.

What may go wrong ?





'---------------------------------------------------------------------------
-----
Private Const pcfTransparency As Double = 1


'---------------------------------------------------------------------------
-----
Sub AddRectangle(r As Excel.Range, tOnAction As String)
Dim rect As Shape

Call DelRectangle(r)

'Create the shape
With r.Cells(1, 1)
Set rect = .Parent.Shapes.AddShape(1, .Left, .Top, .Width, .Height)
'Make it invisible
With rect
.Fill.Transparency = pcfTransparency
.Line.Transparency = pcfTransparency
.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column
If tOnAction < vbNullString Then
.OnAction = tOnAction
End If
End With
End With
End Sub


'---------------------------------------------------------------------------
-----
Sub DelRectangle(r As Excel.Range)
Dim rect As Shape

'Delete the shape
With r
For Each rect In .Parent.Shapes
If rect.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column Then
rect.Delete
Exit Sub
End If
Next rect
End With
End Sub


'---------------------------------------------------------------------------
-----
Public Sub SetRectangle()
' Create a test environment
Call AddRectangle(ActiveCell, "Test")
End Sub


'---------------------------------------------------------------------------
-----
Public Sub Test()
' Display a MsgBox
Call MsgBox("It's only a test")
End Sub

<<<<<<<<<<<<<<<<<<<<<<<<<


What I want is automatically getting rid of the freshly created

rectangles
as soon as the
"test"-procedure runs.

Your help is greatly appreciated.

Kind regards,


H.G. Lamy






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macros not appearing in the Tools Macro Macros list

Macros that require arguments are not displayed in Tools=Macro=Macros

Public Sub Test()
Dim rct as Shape, sName as String
Dim rng as Range
' Display a MsgBox
Call MsgBox("It's only a test")
sname = Application.Caller
set rct = ActiveSheet.Shapes(rct)
set rng = rct.TopLeftCell
DelRectangle rng
End Sub

--
Regards,
Tom Ogilvy

"hglamy" wrote in message
...
Hello there,

I copied code the following 4 procedures from a website into an xl code
module,
as the instruction read.

Its intention is to create invisible reactangles around a cell,
which in turn can fire a macro when the "cell" is clicked.
Thereafter, the rectangle shall be deleted again..

However, only 2 of those procedures (SetRectangle and Test) appear in the
macros list, whatever I try.

What may go wrong ?




'---------------------------------------------------------------------------
-----
Private Const pcfTransparency As Double = 1

'---------------------------------------------------------------------------
-----
Sub AddRectangle(r As Excel.Range, tOnAction As String)
Dim rect As Shape

Call DelRectangle(r)

'Create the shape
With r.Cells(1, 1)
Set rect = .Parent.Shapes.AddShape(1, .Left, .Top, .Width, .Height)
'Make it invisible
With rect
.Fill.Transparency = pcfTransparency
.Line.Transparency = pcfTransparency
.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column
If tOnAction < vbNullString Then
.OnAction = tOnAction
End If
End With
End With
End Sub

'---------------------------------------------------------------------------
-----
Sub DelRectangle(r As Excel.Range)
Dim rect As Shape

'Delete the shape
With r
For Each rect In .Parent.Shapes
If rect.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column Then
rect.Delete
Exit Sub
End If
Next rect
End With
End Sub

'---------------------------------------------------------------------------
-----
Public Sub SetRectangle()
' Create a test environment
Call AddRectangle(ActiveCell, "Test")
End Sub

'---------------------------------------------------------------------------
-----
Public Sub Test()
' Display a MsgBox
Call MsgBox("It's only a test")
End Sub

<<<<<<<<<<<<<<<<<<<<<<<<<


What I want is automatically getting rid of the freshly created rectangles
as soon as the
"test"-procedure runs.

Your help is greatly appreciated.

Kind regards,


H.G. Lamy






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Macros not appearing in the Tools Macro Macros list

Thank you, Tom !

Kind regards,

H.G. Lamy

"Tom Ogilvy" schrieb im Newsbeitrag
...
Macros that require arguments are not displayed in Tools=Macro=Macros

Public Sub Test()
Dim rct as Shape, sName as String
Dim rng as Range
' Display a MsgBox
Call MsgBox("It's only a test")
sname = Application.Caller
set rct = ActiveSheet.Shapes(rct)
set rng = rct.TopLeftCell
DelRectangle rng
End Sub

--
Regards,
Tom Ogilvy

"hglamy" wrote in message
...
Hello there,

I copied code the following 4 procedures from a website into an xl code
module,
as the instruction read.

Its intention is to create invisible reactangles around a cell,
which in turn can fire a macro when the "cell" is clicked.
Thereafter, the rectangle shall be deleted again..

However, only 2 of those procedures (SetRectangle and Test) appear in

the
macros list, whatever I try.

What may go wrong ?





'---------------------------------------------------------------------------
-----
Private Const pcfTransparency As Double = 1


'---------------------------------------------------------------------------
-----
Sub AddRectangle(r As Excel.Range, tOnAction As String)
Dim rect As Shape

Call DelRectangle(r)

'Create the shape
With r.Cells(1, 1)
Set rect = .Parent.Shapes.AddShape(1, .Left, .Top, .Width, .Height)
'Make it invisible
With rect
.Fill.Transparency = pcfTransparency
.Line.Transparency = pcfTransparency
.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column
If tOnAction < vbNullString Then
.OnAction = tOnAction
End If
End With
End With
End Sub


'---------------------------------------------------------------------------
-----
Sub DelRectangle(r As Excel.Range)
Dim rect As Shape

'Delete the shape
With r
For Each rect In .Parent.Shapes
If rect.Name = "rectRow" & r.Cells(1, 1).Row & "Col" & _
r.Cells(1, 1).Column Then
rect.Delete
Exit Sub
End If
Next rect
End With
End Sub


'---------------------------------------------------------------------------
-----
Public Sub SetRectangle()
' Create a test environment
Call AddRectangle(ActiveCell, "Test")
End Sub


'---------------------------------------------------------------------------
-----
Public Sub Test()
' Display a MsgBox
Call MsgBox("It's only a test")
End Sub

<<<<<<<<<<<<<<<<<<<<<<<<<


What I want is automatically getting rid of the freshly created

rectangles
as soon as the
"test"-procedure runs.

Your help is greatly appreciated.

Kind regards,


H.G. Lamy






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 do I get my macros from an XLA file to show in Tools Macro Harlan Grove[_2_] Excel Worksheet Functions 0 June 28th 09 11:34 PM
How do I get my macros from an XLA file to show in Tools Macro smartin Excel Worksheet Functions 0 June 28th 09 10:48 PM
Hide macros from Alt-F8 macro list Bill_S Excel Discussion (Misc queries) 2 January 4th 07 09:05 PM
Macros Menu Keeps Appearing Portocar Excel Discussion (Misc queries) 2 November 13th 06 11:35 PM
List the Macros that can be executed from Tools-Macros Rob Bovey Excel Programming 1 July 10th 03 05:34 PM


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