SoundofSpheres
Programmer
Well I am onto part 2 of my project, and am trying to get some more code to work. here is what I am doing: I want to have a checkbox representing each subsequent sheet all on one sheet. The checkbox value will be 1 if pictures exist on subsequent sheets, and 0 if no image exists. Also, I keep delete shapes with my AddPicture code.
here is the module code:::
and here is the activeworksheet code that I am working on now and having problems with::::
thanks for all your help guys. and thanks to skip, I know hes gunna enlighten me on my errors in this...
regards,
Corey
here is the module code:::
Code:
Sub AddPictures()
Dim w As Worksheet
Dim strFilePath As String
Dim shp As Shape
On Error Resume Next
Application.ScreenUpdating = False
Sheets("AP1").Select
For Each w In Worksheets
Application.StatusBar = " Adding Picture to " & w.Name & "..."
'For Each shp In w.Shapes
' If shp.Name = w.[b4] Then shp.Delete
'Next shp
Call RemoveExtraPics
strFilePath = (ActiveWorkbook.Path) & ("\Pictures\") & (w.[b4]) & (".jpg")
Range("H1").Select
If Len([b4]) > 0 Then
Set Picture = Sheets(w.Name).Pictures.Insert(strFilePath)
w.Shapes.Line.Weight = 2
Picture.Name = w.[b4]
Picture.Top = Picture.TopLeftCell.Top
Picture.Top = [a23:F55].Top
Picture.Left = Picture.TopLeftCell.Left
Picture.Left = [a23].Left
Picture.Width = 658
strFilePath = ""
End If
Next
Application.StatusBar = ("Removing unnecessary artifacts...")
Sheets("Survey").Select
Call RemoveExtraPics
Call ValidateImg
On Error GoTo 0
End Sub
'++++++++++++++++++++++++++++++++++++++++++++++++
Function RemoveExtraPics()
Dim n As Long, shCount As Long
Dim w As Worksheet
shCount = ActiveSheet.Shapes.Count
If Not shCount > 1 Then Exit Function
For n = 1 To shCount - 1
With ActiveSheet.Shapes(n)
If InStr(.Name, ActiveSheet.[b4]) > 0 Then
.Delete
End If
End With
Next
End Function
'++++++++++++++++++++++++++++++++++++++++++++++++
Public Function ValidateImg()
Application.StatusBar = ("validating Pictures in each sheet...")
For Each w In Worksheets
Application.ScreenUpdating = True
w.Activate
Next
Sheets("AP1").Select
Application.StatusBar = (" Done")
End Function
'++++++++++++++++++++++++++++++++++++++++++++++++
Sub DeletePictures()
Dim w As Worksheet
Dim shp As Shape
On Error Resume Next
For Each w In Worksheets
For Each shp In w.Shapes
If shp.Name = w.[b4] Then shp.Delete
Next shp
Next w
On Error GoTo 0
Call ValidateImg
End Sub
'++++++++++++++++++++++++++++++++++++++++++++++++
Public Function CheckShape(isShp As String) As Boolean
On Error Resume Next
tmpID = ActiveSheet.Shapes(isShp).ID
If IsEmpty(tmpID) Then
isShp = False
'MsgBox "picture does not exists! "
Else
isShp = True
'MsgBox "picture does exist"
End If
On Error GoTo 0
End Function
and here is the activeworksheet code that I am working on now and having problems with::::
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim chk As CheckBox
Dim w As Worksheet
Dim shp As Shape
'I am trying to cycle through all of the check boxes on the 'sheet and determine if it needs a check or not. removed 'for testing.
'For Each shp In Sheets("Survey").Shapes
For Each w In Worksheets
If CheckShape(w.[b4]) = False Then
MsgBox (w.[b4] & " False")
Sheets("Survey").[Check Box 7].Value = 0
Else
ActiveSheet.[Check Box 6].Value = 1
MsgBox (w.[b4] & " True")
End If
'Next
Next
End Sub
thanks for all your help guys. and thanks to skip, I know hes gunna enlighten me on my errors in this...
regards,
Corey