简体   繁体   English

访问-Excel列表导出替换值

[英]Access - Excel List Export replace Values

I have an Excel Report, there are values in Access which only have TRUE/FALSE Answers. 我有一个Excel报表,Access中的值只有TRUE / FALSE答案。 How can I change these values each report to (for example) Open/Closed. 如何将每个报表的这些值更改为(例如)打开/关闭。

For this report I have got a query (excel_open_projects) which gets all the value I need. 对于此报告,我有一个查询(excel_open_projects),该查询可获取我需要的所有值。

Path = CurrentProject.Path & "\"
filename = "Open_Projects_" & Format(Now(), "YYYYMMDDHHNNSS") & ".xls"

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel2003, "excel_open_projects", Path & filename

I have already got a code which changes the Values in the first row: 我已经有了更改第一行中的“值”的代码:

Public Sub openXL()
'Variables to refer to Excel Objects
Dim MySheetPath As String
Dim Xl As Excel.Application
Dim XlBook As Excel.Workbook
Dim XlSheet As Excel.Worksheet
Dim row_count, i As Integer

' Tell it location of actual Excel file
MySheetPath = Path & filename
MsgBox MySheetPath

'Open Excel and the workbook
Set Xl = CreateObject("Excel.Application")
Set XlBook = GetObject(MySheetPath)

'Make sure excel is visible on the screen
Xl.Visible = True
XlBook.Windows(1).Visible = True

'Define the sheet in the Workbook as XlSheet
Set XlSheet = XlBook.Worksheets(1)

'Insert Row and the Value in the excel sheet starting at specified cell
XlSheet.Range("A1") = "Column A"

'Clean up and close worksheet
XlBook.Save
XlBook.Close

Set Xl = Nothing
Set XlBook = Nothing
Set XlSheet = Nothing

End Sub

Thanks for your help in advance! 谢谢您的帮助!

I have solved the Problem: 我已经解决了问题:

For i = 1 To row_count
If XlSheet.Range("Y" & i) = "True" Then
XlSheet.Range("Y" & i) = "Yes"
ElseIf XlSheet.Range("Y" & i) = "False" Then
XlSheet.Range("Y" & i) = "No"
End If
Next

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM