View Object in a protected sheet

Sagittariu5

New Member
Joined
Oct 30, 2013
Messages
5
Hello All

Being new to the forum as well as self taught in VBA was hoping for some insight

I'm trying to find a way to enable me to just VIEW object(s) inserted (below Code) in a Projected sheet, WITHOUT tamparing (deleting, changing) or editing the object.

Code:
Private Sub Insert_OLE_Object()
    ActiveWorkbook.Unprotect Password:=""
    Sheets("BackUp").Unprotect Password:=""
    
    FinalRow = Cells(Rows.Count, "C").End(xlUp).Row
    Range("C" & FinalRow).Select
'
  Dim iconToUse As String
  Dim fullFileName As String
  Dim FNExtension As String
  
' Ask which file to Insert
        x = Application.GetOpenFilename( _
            FileFilter:="All Files (*.*), *.*", _
            Title:="Choose File to Insert", MultiSelect:=False)#
 
    'Choose an icon based on filename extension get all after last "." in filename
           FNExtension = Right(x, Len(x) - InStrRev(x, "."))
    
    'Select icon based on filename extension
          Select Case UCase(FNExtension)
                Case Is = "TXT"
                  iconToUse = "C:\WINDOWS\system32\Packager.exe"
            
                Case Is = "XLS", "XLSM", "XLSX"
                  iconToUse = "C:\WINDOWS\Installer\{90120000-0012-0000-0000-0000000FF1CE}\xlicons.exe"
            
                Case Is = "DOC", "DOCM", "DOCX"
                  iconToUse = "C:\WINDOWS\Installer\{90120000-0012-0000-0000-0000000FF1CE}\wordicon.exe"
            
                Case Is = "PDF"
                  iconToUse = "C:\WINDOWS\Installer\{AC76BA86-7AD7-1033-7B44-A81000000003}\PDFFile_8.ico"
            
                Case Else
                  'This is a generic icon
                  iconToUse = "C:\Windows\system32\packager.dll"
          End Select
    
        Worksheets("BackUp").OLEObjects.Add(fileName:=x, Link:=False, _
                    DisplayAsIcon:=True, IconFileName:=iconToUse, IconIndex:=0, IconLabel:=GetFileNameWithoutExt(x)).Activate
            
         ActiveCell.Offset(1, 0).Select
         
        ' Check in case no files were selected
            If x = "False" Then Exit Sub
                   
            ActiveWorkbook.Protect Password:=""
            ActiveWorkbook.Protect Password:=""
            Sheets("Main Reconciliation").Select
    
End Sub

Hoping someone could point me in the right direction.

Kind Regards
Sagittariu5</SPAN></SPAN>
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top