Solved

Excel opened as 'read only'

Posted on 2007-11-14
3
1,094 Views
Last Modified: 2008-02-01
I have the attached code below, whic searches for an excel file and then opens the one it finds. However, it opens as a read only file. I need it to open as read-write. Can someone please explain to me what, in the code, is causing the read-only status and how to resolve it?
For Each FoundFile As String In My.Computer.FileSystem.GetFiles(My.Settings.DefFolder, _

        FileIO.SearchOption.SearchAllSubDirectories, "*.xls")

            ' add each found file to the list box

            ' search each file for the specified string

            Dim xlApp As Object = CreateObject("Excel.Application")

            Dim xlWB As Object = xlApp.Workbooks.Open(FoundFile)

            Dim xlWS As Object = xlWB.Worksheets("Sheet1")

            Dim xlFndCell As Object = xlWS.Cells.Find(SearchBox.Text, , -4163, 1)

            If Not xlFndCell Is Nothing Then

                If xlWS.range("E21").value.ToString = SearchBox.Text Then

                    FileNm = """" + FoundFile + """"

                    ProcID = Shell("C:\Program Files\Microsoft Office\Office\excel.exe " & FileNm, AppWinStyle.NormalFocus)

                    ' Activate the application.

                    AppActivate(ProcID)

*** At this point the Excel file opens as a read-only

Open in new window

0
Comment
Question by:evault
3 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 20286209
By default, the only reason it would open in read-only mode is if was already open by another process before attempting to open it.  There is a command line switch to force read-only, so without that, you would assume it would open in read-write whenever possible.

http://support.microsoft.com/kb/291288

Regards,

Rob.
0
 
LVL 25

Accepted Solution

by:
imitchie earned 250 total points
ID: 20288431
does
Dim xlWB As Object = xlApp.Workbooks.Open(FoundFile)
open it once (non-visible), and
ProcID = Shell("C:\Program Files\Microsoft Office\Office\excel.exe " & FileNm, AppWinStyle.NormalFocus)
a second time? (different process caused by shell)
0
 

Expert Comment

by:Bacliff
ID: 20586581
Open Excel Read/Write
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now