Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I have been using VB and C# in Visual Studio for a long time but never used it with Excel. I have an Excel sheet with 16 images. Each one in each cell and having a name of img1, img2, .... I have some VB code which I want to run. When I run it am I asked for a Macro name. Could someone, please, give me some tips on how to run this game code? Here is the code: Option Explicit ' TYPES ' GameType Type GameType img(1 To 6, 1 To 6) As String LastRow As Integer LastCol As Integer Score As Integer End Type ' GameType ' VARIABLES Public game As GameType ' METHODS ' MyWait Sub MyWait(ByVal wt As Single) Dim t As Single t = Timer Do Loop Until Timer - t wt End Sub ' MyWait ' Positioning Sub Positioning(ByRef game As GameType, 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 = game.img(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 ' Positioning ' Hide Sub Hide(ByRef game As GameType, ByVal r As Integer, ByRef c As Integer) With game ActiveSheet.Shapes(.img(r, c)).Visible = False End With DoEvents End Sub ' Hide ' Show Sub Show(ByRef game As GameType, ByVal r As Integer, ByRef c As Integer) With game ActiveSheet.Shapes(.img(r, c)).Visible = True End With DoEvents End Sub ' Show ' IsVisible Function IsVisible(ByRef game As GameType, ByVal r As Integer, ByRef c As Integer) As Boolean With game IsVisible = ActiveSheet.Shapes(.img(r, c)).Visible End With End Function ' IsVisible Thanks, Miguel |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I update VBA code in a module that is running my VBA code? | Excel Programming | |||
Code is not running | Excel Programming | |||
how to prevent code running when in a worksheet code | Excel Programming | |||
Running Code from Add-Ins | Excel Programming | |||
running code | New Users to Excel |