I
Inquisitive1
I am having fun trying to incorporate VBA code with my assignments. I
have run into a problem opening an Excel file from Access 2000 VBA -
the Excel file keeps opening as "Read-Only". My goal is to open the
Excel file and change the value of a cell to the value of a variable in
code (is that even possible, or can cells in Excel only be updated with
recordsets?). Here is my code so far...
Public Function ScorecardCreateDate()
On Error GoTo Err_ScorecardCreateDate
Dim strFile As String
Dim ScorecardFileDate As Date
Dim NMLPPMFileDate As Date
Dim NMLFileDate As Date
strFile = "C:\Metrics\Scorecards\ManufacturingOnlyScores.xls"
ScorecardFileDate = FileDateTime(strFile)
strFile = "C:\Metrics\NewModelLaunch\NML-PartLevelRisk.xls"
NMLFileDate = FileDateTime(strFile)
strFile = "C:\Metrics\Ppm\CYTD PPM\Exception
Reports\NML_CYTDPPM.xls"
NMLPPMFileDate = FileDateTime(strFile)
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim strFileName As String
strFileName = "C:\Metrics\Ppm\CYTD PPM\Exception
Reports\NML_CYTDPPM.xls"
Set xlBook = xlApp.Workbooks.Open(strFileName, , False, , , False,
True)
xlApp.Application.Visible = True
Set xlSheet = xlBook.Worksheets("ReportDates")
xlSheet.Activate
xlSheet.Range("B1").Value = NMLFileDate
Set xlApp = Nothing
Set xlBook = Nothing
Exit_ScorecardCreateDate:
Exit Function
Err_ScorecardCreateDate:
MsgBox Err.Description
Resume Exit_ScorecardCreateDate
End Function
have run into a problem opening an Excel file from Access 2000 VBA -
the Excel file keeps opening as "Read-Only". My goal is to open the
Excel file and change the value of a cell to the value of a variable in
code (is that even possible, or can cells in Excel only be updated with
recordsets?). Here is my code so far...
Public Function ScorecardCreateDate()
On Error GoTo Err_ScorecardCreateDate
Dim strFile As String
Dim ScorecardFileDate As Date
Dim NMLPPMFileDate As Date
Dim NMLFileDate As Date
strFile = "C:\Metrics\Scorecards\ManufacturingOnlyScores.xls"
ScorecardFileDate = FileDateTime(strFile)
strFile = "C:\Metrics\NewModelLaunch\NML-PartLevelRisk.xls"
NMLFileDate = FileDateTime(strFile)
strFile = "C:\Metrics\Ppm\CYTD PPM\Exception
Reports\NML_CYTDPPM.xls"
NMLPPMFileDate = FileDateTime(strFile)
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim strFileName As String
strFileName = "C:\Metrics\Ppm\CYTD PPM\Exception
Reports\NML_CYTDPPM.xls"
Set xlBook = xlApp.Workbooks.Open(strFileName, , False, , , False,
True)
xlApp.Application.Visible = True
Set xlSheet = xlBook.Worksheets("ReportDates")
xlSheet.Activate
xlSheet.Range("B1").Value = NMLFileDate
Set xlApp = Nothing
Set xlBook = Nothing
Exit_ScorecardCreateDate:
Exit Function
Err_ScorecardCreateDate:
MsgBox Err.Description
Resume Exit_ScorecardCreateDate
End Function