Solved

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

Posted on 2014-11-17
4
337 Views
Last Modified: 2014-11-17
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
0
Comment
Question by:f19l
  • 2
  • 2
4 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40447402
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
0
 

Author Comment

by:f19l
ID: 40447488
Tried that but still getting the same problem.
0
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40447577
How about Trusting the directory:

1. Go to File - Options - Trust Center.
2. Click on Trust Center Settings...
3. Go to Trusted Locations.
4. If the folder is a network location, click "Allow Trusted Locations on my network".
5. Click on Add new location... and add the folder to the locations.
0
 

Author Comment

by:f19l
ID: 40447646
Thanks. That works.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question