Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read Only when opening an Excel spreadsheet from Access

Status
Not open for further replies.

RomeERome

Programmer
Nov 17, 2003
45
US
Hello,

I am opening an Excel spreadsheet from Access 2007, and when I try to change the data in that spreadsheet, and save it, it tells me that it's in read-only mode, and I have to do a Save As and change the name.

Is there a way to open the spreadsheet in edit mode. Below is my code that I currently have working.

Code:
    Dim xlApp As Excel.Application
    Dim sht As Excel.Worksheet
    Dim strFilename As String
    
    strFilename = "Drive Letter:\Filename.xlsx"
    
    Set xlApp = CreateObject("Excel.Application")
    xlApp.Workbooks.Open (strFilename)
    Set sht = xlApp.ActiveWorkbook.Sheets(1)
    sht.Activate
    xlApp.Application.Visible = True
    
    Set xlApp = Nothing
    Set sht = Nothing

Any help would be greatly appreciated.


 


hi,

Try this...
Code:
    Dim xlApp As Excel.Application
    Dim sht As Excel.Worksheet
    Dim strFilename As String
    
    strFilename = "Drive Letter:\Filename.xlsx"
    
    Set xlApp = CreateObject("Excel.Application")
    xlApp.Application.Visible = True
'this is the workbook object
    with xlApp.Workbooks.Open (strFilename)
       Set sht = .Sheets(1)
       sht.Activate
    
       xlApp.Displayalerts = false
       .Save
       .close
    end with

    xlApp.Quit
    Set xlApp = Nothing
    Set sht = Nothing

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top