changefileaccess xlreadwrite (1 Viewer)

radek225

Registered User.
Local time
Today, 05:55
Joined
Apr 4, 2013
Messages
307
I try to open Excel file from Ms Access do some changes and quit. The problem is, I can't open in readwrite mode:/. my code is

Code:
Dim mojexcel As Object
Set mojexcel = CreateObject("Excel.application")
mojexcel.Visible = True
Set wb = mojexcel.workbooks.Open("C:\Users\xw\Desktop\Robocza\ww.xlsx")

wb.worksheets(1).cells(1, 1) = "a2111"
wb.Close
mojexcel.Quit

If I try to use
Code:
wb.changefileaccess xlreadwrite
get error "the attempt failed" in addition I want to create password for my workbook. How should I do this?
 

Rx_

Nothing In Moderation
Local time
Today, 06:55
Joined
Oct 22, 2009
Messages
2,803
Almost missed this one over here.
In the Excel forum, we also assist in Excel VBA from MS Access
http://www.access-programmers.co.uk/forums/forumdisplay.php?f=55

Code:
Private Sub OpenAndEditExcelFromAccess()
' In Access VBA module - in Tools Reference - Set reference to Excel
 Dim MyXLSheetPath As String
 Dim Xl         As Object
 Dim XlBook     As Object
 Dim XlSheet    As Object
MyXLSheetPath = (CurrentProject.path & "\MustAlreadyExist.xlsx")
Set Xl = CreateObject("Excel.Application")
Set XlBook = GetObject(MyXLSheetPath)
Xl.Visible = True
XlBook.Windows(1).Visible = True
Set XlSheet = XlBook.Worksheets(1)
XlSheet.Rows(2).EntireRow.Insert
 XlSheet.Range("A2") = "UK Access Programmers"
Set Xl = Nothing
 Set XlBook = Nothing
 Set XlSheet = Nothing
End Sub
 

Users who are viewing this thread

Top Bottom