Link to home
Start Free TrialLog in
Avatar of f19l
f19l

asked on

How do I open an .xls file in 64-bit version of excel without it being in protected view?

Hello,

I recently upgraded my excel version from 32-bit to 64-bit. I currently use a spreadsheet that runs a macro that saves a file received via email each day to a local folder and then open it up for use. In the 32-bit my VB coding worked without any issue. Now however when I run the code I get the following error message:

Run-time error

Office has detected a problem with this file. To help protect your computer this file cannot be opened.

I have to manually go into the directory, open the file and enable it to be opened in edit view.

Below is the current code

Public Sub GetAttachments_CURE()
Dim FileName As String
 Dim i As Integer
 Dim timestamp As Date
 Dim filecheck As Boolean
 Dim ASK As String
 Dim TRYBOOK As String
 Dim Txt As String
 Dim Itemcheck As Object
 
 TRYBOOK = ActiveWorkbook.Name
 
 filecheck = False
 Set Itemcheck = Nothing
 Set olkAPp = CreateObject("outlook.application")
 Set ns = olkAPp.GetNamespace("MAPI")
 Set Inbox = olkAPp.Session.Folders("London MO - Rates").Folders("Inbox")
 i = 0
 
 If Inbox.Items.Count = 0 Then
    MsgBox "There are no messages in the Inbox.", vbInformation, "Nothing Found"
    Exit Sub
 End If
 
 For Each Item In Inbox.Items
 
   For Each Atmt In Item.Attachments
     If Left(Atmt, 7) <> "Picture" And Left(Atmt, 5) <> "image" Then
        If LCase(Atmt.FileName) Like "*.xls*" Then
           If Atmt.FileName = "MO_London_Rates.xls" Then
                If Dir("C:\Temp\CURE.xls") <> "" Then
                   Kill "C:\Temp\CURE.xls"
                End If
                FileName = "C:\Temp\CURE.xls"
                Atmt.SaveAsFile FileName
                Workbooks.Open ("C:\Temp\CURE.xls")
                If Mid(Range("A6").Value, 45, 2) & "/" & Mid(Range("A6").Value, 42, 2) & "/" & Mid(Range("A6").Value, 48, 4) <> Format(Now(), "DD/MM/YYYY") Then
                   MsgBox "The CURE file contains old data!!!", vbOKOnly + vbExclamation, "OLD DATA!!!"
                End If
                Range("A6:F300").Select
                Selection.Copy
                Workbooks(TRYBOOK).Activate
                Sheets("CURE_Flat").Select
                Range("A6").Select
                ActiveSheet.Paste
                ActiveSheet.Calculate
                Exit Sub
           End If
        End If
     End If
   Next Atmt
'Line1:

Next Item
'goto exitSub
 
'GetAttachments_exit:
   Set Atmt = Nothing
   Set Item = Nothing
   Set ns = Nothing
'   GoTo Line1
'GetAttachments_err:
 
'   Resume GetAttachments_exit
'exitSub:
MsgBox "NO CURE FILE PRESENT!!!"

End
End Sub
Avatar of Phillip Burton
Phillip Burton

Having you Signed the VBA code?

If not, go to SelfCert.exe (on my computer it's in E:\Program Files (x86)\Microsoft Office 2010\Office14\Selfcert.exe, but it may vary on your computer), create a certificate, then in Excel VBA's editor:

Go to Tools - Digital Signature
Click Choose...
Select your signature
Then save your file
Avatar of f19l

ASKER

Tried that but still getting the same problem.
ASKER CERTIFIED SOLUTION
Avatar of Phillip Burton
Phillip Burton

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of f19l

ASKER

Thanks. That works.