TOPページ


Excelでゲームを作ってみる
シュールなフリゲー生きろをExcelで再現

★1 背景処理とマクロの連動

今回のコード


Sub Add_Shapes()
    
    W = 15
    H = 15
    
    For x = 3 To 25
    For y = 17 To 53
        
        With Cells(x, y)
            L = .Left
            T = .Top
        End With
        
        ActiveSheet.Shapes.AddShape(msoShapeRectangle, L, T, W, H).Select
        
        With Selection.ShapeRange
            .Line.Visible = msoFalse
            .Name = x & "_" & y
        End With
        
    Next
    Next
    
End Sub

Sub Backimg_up() D_Path = ThisWorkbook.Path & "\img\" For s = 1 To ActiveSheet.Shapes.Count Set obj = ActiveSheet.Shapes(s) xy = Split(obj.Name, "_") x = CSng(xy(0)) y = CSng(xy(1)) imgNo = Cells(x, y) F_Path = D_Path & imgNo & ".png" obj.Fill.UserPicture F_Path AStr = "'map(""" & obj.Name & """)'" obj.OnAction = AStr Next End Sub

Naviator 企画
INFO:NaviatorEnterprise.com