S
shapper
Hello,
I have a Worksheet with 36 images all them having a name.
I also have a button that run clicked runs the Macro "Play". And I
have the following code:
Private Sub Workbook_Open()
Option Explicit
Type TpJogo
fig(1 To 6, 1 To 6) As String
LastRow As Integer
LastCol As Integer
Score As Integer
End Type ' TpJogo
Public jogo As TpJogo
Sub Play()
With jogo
.fig = ("gar2")
.LastRow = 8
.LastCol = 7
.Score = 0
End With
Coloca_Pos(jogo, 6, 6) = 1
End Sub
Sub Coloca_Pos(ByRef jogo As TpJogo, ByVal r As Integer, ByVal c As
Integer)
Dim hc As Single, hf As Single, wc As Single, wf As Single
Dim nf As String
On Error GoTo fim
With Range("tabuleiro")
hc = .Cells(r, c).Height
wc = .Cells(r, c).Width
nf = jogo.fig(r, c)
hf = ActiveSheet.Shapes(nf).Height
wf = ActiveSheet.Shapes(nf).Width
ActiveSheet.Shapes(nf).Top = .Cells(r, c).Top + (hc - hf) / 2
ActiveSheet.Shapes(nf).Left = .Cells(r, c).Left + (wc - wf) / 2
End With
fim:
End Sub ' Coloca_Pos
End Sub
When I click the I get the following error:
User-defined type not defined.
What am I doing wrong?
Thanks,
Miguel
I have a Worksheet with 36 images all them having a name.
I also have a button that run clicked runs the Macro "Play". And I
have the following code:
Private Sub Workbook_Open()
Option Explicit
Type TpJogo
fig(1 To 6, 1 To 6) As String
LastRow As Integer
LastCol As Integer
Score As Integer
End Type ' TpJogo
Public jogo As TpJogo
Sub Play()
With jogo
.fig = ("gar2")
.LastRow = 8
.LastCol = 7
.Score = 0
End With
Coloca_Pos(jogo, 6, 6) = 1
End Sub
Sub Coloca_Pos(ByRef jogo As TpJogo, ByVal r As Integer, ByVal c As
Integer)
Dim hc As Single, hf As Single, wc As Single, wf As Single
Dim nf As String
On Error GoTo fim
With Range("tabuleiro")
hc = .Cells(r, c).Height
wc = .Cells(r, c).Width
nf = jogo.fig(r, c)
hf = ActiveSheet.Shapes(nf).Height
wf = ActiveSheet.Shapes(nf).Width
ActiveSheet.Shapes(nf).Top = .Cells(r, c).Top + (hc - hf) / 2
ActiveSheet.Shapes(nf).Left = .Cells(r, c).Left + (wc - wf) / 2
End With
fim:
End Sub ' Coloca_Pos
End Sub
When I click the I get the following error:
User-defined type not defined.
What am I doing wrong?
Thanks,
Miguel