0
액세스 권한이없는 Excel 통합 문서를 생성하고 서식을 지정하려고합니다. 파일을 쉽게 만들 수는 있지만 포맷에 어려움이 있습니다.Access VBA에서 사용하는 Excel 응용 프로그램 속성
파일 생성
Dim xl As Object
'This deals with Excel already being open or not
On Error Resume Next
Set xl = GetObject(, "Excel.Application")
On Error GoTo 0
If xl Is Nothing Then
Set xl = CreateObject("Excel.Application")
End If
Set XlBook = GetObject(xlsxPath)
'filename is the string with the link to the file ("C:/....blahblah.xls")
'Make sure excel is visible on the screen
xl.Visible = True
XlBook.Windows(1).Visible = True
'xl.ActiveWindow.Zoom = 75
'Define the sheet in the Workbook as XlSheet
Set xlsheet1 = XlBook.Worksheets(1)
'Format
With xlsheet1
xlsheet1.Rows("1:1").Select
여기 내 오류가 문자열
strCurrentDBName = CurrentDb.Name
For i = Len(strCurrentDBName) To 1 Step -1
If Mid(strCurrentDBName, i, 1) = "\" Then
strPath = Left(strCurrentDBName, i)
Exit For
End If
Next
xlsxPath = strPath & "Report.xlsx"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "Report", xlsxPath, True
MsgBox ("Report generated. " & xlsxPath)
형식으로 희미한 strCurrentDBName (런타임 오류 '1004': 응용 프로그램 정의 또는 개체 정의 오류)
xlsheet1.Range(xl.Selection, xl.Selection.End(xlDown)).Select
xlsheet1.Selection.EntireRow.AutoFit
End With