I have this code in ThisWorkbook (below) and I need to add a shape named "Rounded Rectangle 3" which is in sheet "CHIT1&2", shape named "Rounded Rectangle 2" which is in sheet "CHIT3&4 and shape named "Rounded Rectangle 7" which is in sheet "CHIT5&6". I need the colour to be RGB(176,245,254).
Any help?
You want to create shapes. They should be placed somewhere on the worksheet, for example covering cell B2, or covering cells C3:E4, or similar. Where would you prefer to have them?
Thank you for understand me. Yes that what I needed.
Actually I need another code that every time I click these buttons, these shapes become No Fill. Is it possible?
Sorry I forgot to tell you that these buttons are assigned to Macros.
Actually I want to remove the fill color only when I click on the button then after I save, it will appear again with fill color.
Thanks
Hi Master I can't managed to do it. I think I am not putting those lines in their right place. Will I give you a link of the file so that you can try it?
Thanks
I'm confused now. You stated that "I want to remove the fill color only when I click on the button then after I save, it will appear again with fill color".
But in the macro assigned to the shape, you save the workbook. So the fill color would be removed by clicking, then immediately applied again because you save the workbook...
Sub SAVE()
Dim strPath As String
strPath = CreateObject("WScript.Shell").SpecialFolders("Desktop")
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strPath & "\Save chits\" & Range("J8").Value & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
ActiveSheet.PrintOut
' Remove fill color from button
ActiveSheet.Shapes(Application.Caller).Fill.Visible = False
End Sub
Master Hans,
I have 366 files to modify. I used the code below to modify Module4 and had no problems. The problem is the one in ThisWorkbook because when I tried to do it like I did to modify Module4, it gave me a lot of errors. Do you think I have to do them file by file or there is an easier way?
Thanks.
Sub ReplaceText()
Const OldText = "Write old text"
Const NewText = "Write new text"
Dim Folder As String
Dim File As String
Dim Wbk As Workbook
Dim NumLines As Long
Dim Lines As String
With Application.FileDialog(4) ' msoFileDialogFolderPicker
If .Show Then
Folder = .SelectedItems(1)
Else
MsgBox "You didn't select a folder!", vbExclamation
Exit Sub
End If
End With
Application.ScreenUpdating = False
Folder = Folder & "\"
File = Dir(Folder & "*.xlsm")
Do While File <> ""
If UCase(File) <> UCase(ThisWorkbook.Name) Then
Set Wbk = Workbooks.Open(Folder & File)
With Wbk.VBProject.VBComponents("Module1").CodeModule
NumLines = .CountOfLines
Lines = .Lines(1, NumLines)
Lines = Replace(Lines, OldText, NewText)
.DeleteLines 1, NumLines
.AddFromString Lines
End With
Wbk.Close SaveChanges:=True
End If
File = Dir
Loop
Application.ScreenUpdating = True
MsgBox Ct & " Module 1 updated"
End Sub
Sub ReplaceText()
Const OldText = "Write old text"
Const NewText = "Write new text"
Dim Folder As String
Dim File As String
Dim Wbk As Workbook
Dim NumLines As Long
Dim Lines As String
With Application.FileDialog(4) ' msoFileDialogFolderPicker
If .Show Then
Folder = .SelectedItems(1)
Else
MsgBox "You didn't select a folder!", vbExclamation
Exit Sub
End If
End With
Application.ScreenUpdating = False
Folder = Folder & "\"
File = Dir(Folder & "*.xlsm")
Do While File <> ""
If UCase(File) <> UCase(ThisWorkbook.Name) Then
Set Wbk = Workbooks.Open(Folder & File)
With Wbk.VBProject.VBComponents("Module1").CodeModule
NumLines = .CountOfLines
Lines = .Lines(1, NumLines)
Lines = Replace(Lines, OldText, NewText)
.DeleteLines 1, NumLines
.AddFromString Lines
End With
Wbk.Close SaveChanges:=True
End If
File = Dir
Loop
Application.ScreenUpdating = True
MsgBox Ct & " Module 1 updated"
End Sub