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

ここにいくつかのコードがあります

Excelですべての列と行の見出しを非表示にするVBAコードを作成する方法は?

which I don't quite know where it needs to be placed in with the code I am already using.

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

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 に答える