2

这是我正在使用的代码。

它工作正常,但我需要知道排除列标题需要哪些额外代码。

Private Sub Command104ContrDonatWeekly_Click()
On Error GoTo Command104ContrDonatWeekly_Click_Err

    DoCmd.OpenQuery "Contributors Who Donated in Past Week", acViewNormal, acEdit

    xlfile = "C:\Users\Michael1\Desktop\KSN\DistributionListWeekly.xlsb"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, _
    "Contributors Who Donated in Past Week", xlfile, True, "EmailList"

    Shell "Excel.exe " & xlfile, vbNormalFocus

Command104ContrDonatWeekly_Click_Exit:
    Exit Sub

Command104ContrDonatWeekly_Click_Err:
    MsgBox Error$
    Resume Command104ContrDonatWeekly_Click_Exit

End Sub

这是一些代码

如何编写 VBA 代码以隐藏 Excel 中的所有列和行标题?

我不太清楚它需要与我已经使用的代码一起放在哪里。

Private Sub hideHeadings()
  Dim wrkbk As Workbook
  Dim wrksh As Worksheet
  Dim prev As Window

  Set prev = ActiveWindow

  For Each wrkbk In Workbooks
    For Each wrksh In wrkbk.Worksheets
        wrksh.Activate
        ActiveWindow.DisplayHeadings = False
    Next wrksh
  Next wrkbk

  prev.Activate

End Sub
4

2 回答 2

1

从访问:

Sub XLTrans()
''Reference: Microsoft ActiveX Data Object x.x Library
Dim rs As New ADODB.Recordset
Dim xl As Object ''Excel.Application
Dim wb As Object ''Workbook

Set xl = CreateObject("Excel.Application")

Set wb = xl.Workbooks.Add

''Connection relevant for 2007 or 2010
rs.Open "MyTableOrQuery", CurrentProject.AccessConnection

wb.Sheets(1).Cells(1, 1).CopyFromRecordset rs

xl.Visible = True

End Sub
于 2012-04-17T18:25:26.807 回答
0

If you insist on using the transferspreadsheet;

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "tbl_one", xlfile, True

Dim xl As Object
Dim wb As Object

Set xl = CreateObject("Excel.Application")
Set wb = xl.Workbooks.Open(xlfile)

xl.DisplayAlerts = False
With wb.Worksheets(1)
    .Rows(1).Delete
End With
wb.Save
xl.Visible = True
于 2014-08-06T10:34:13.460 回答