code到从Access 2007年转移到Excel 2007中排除列标题标题、转移到、Access、code

由网友(梦里有她、别叫醒我)分享简介:下面是我现在用的是code。它工作正常,但我需要知道什么额外的code需要排除的列标题。私人小组Command104ContrDonatWeekly_Click()对错误转到Command104ContrDonatWeekly_Click_ErrDoCmd.OpenQuery贡献者,他们在过去一周捐赠,acViewN...

下面是我现在用的是code。

它工作正常,但我需要知道什么额外的code需要排除的列标题。

 私人小组Command104ContrDonatWeekly_Click()
对错误转到Command104ContrDonatWeekly_Click_Err

    DoCmd.OpenQuery贡献者,他们在过去一周捐赠,acViewNormal,acEdit

    xlfile =C:用户 Michael1 桌面 KSN  DistributionListWeekly.xlsb
    DoCmd.TransferS preadsheet acExport,ACS preadsheetTypeExcel12,_
    贡献者,他们在过去一周捐赠,xlfile,真,的emailList

    壳牌Excel.exe中&放大器; xlfile,vbNormalFocus

Command104ContrDonatWeekly_Click_Exit:
    退出小组

Command104ContrDonatWeekly_Click_Err:
    MSGBOX错误$
    简历Command104ContrDonatWeekly_Click_Exit

结束小组
 

下面是一些code从

How编写VBA code可以隐藏所有在Excel中列和行标题?

我不太知道它需要放在与我已经使用了code。

 私人小组hideHeadings()
  昏暗wrkbk作为工作簿
  昏暗wrksh作为工作表
  昏暗$ P $光伏作为窗口

  设置preV =的ActiveWindow

  对于每个wrkbk在工作簿
    对于每个wrksh在wrkbk.Worksheets
        wrksh.Activate
        ActiveWindow.DisplayHeadings =假
    接下来wrksh
  接下来wrkbk

  prev.Activate

结束小组
 
怎么把Access2007数据库中的表导出到Excel中

解决方案

从访问:

 子XLTrans()
''引用:Microsoft ActiveX数据对象XX库
昏暗的RS作为新ADODB.Recordset
昏暗XL作为对象''Excel.Application
昏暗的世行作为对象''工作簿

设置XL =的CreateObject(Excel.Application)

设置白平衡= xl.Workbooks.Add

''连接相关的2007或2010
rs打开MyTableOrQuery,CurrentProject.AccessConnection

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

xl.Visible = TRUE

结束小组
 

Here's the code which I am using.

It works fine, but I need to know what additional code is required to exclude the column headings.

Private Sub Command104ContrDonatWeekly_Click()
On Error GoTo Command104ContrDonatWeekly_Click_Err

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

    xlfile = "C:UsersMichael1DesktopKSNDistributionListWeekly.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

Here's some code from

How to write VBA code to hide all the column and row headings in Excel?

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

解决方案

From Access:

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

阅读全文

相关推荐

最新文章