code到从Access 2007年转移到Excel 2007中排除列标题 [英] Code to Exclude Column Headings from Transferring to Excel 2007 from Access 2007

查看:196
本文介绍了code到从Access 2007年转移到Excel 2007中排除列标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我现在用的是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从

<一个href="http://stackoverflow.com/questions/3624110/how-to-write-vba-$c$c-to-hide-all-the-column-and-row-headings-in-excel">How编写VBA code可以隐藏所有在Excel中列和行标题?

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

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

  设置preV =的ActiveWindow

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

  prev.Activate

结束小组
 

解决方案

从访问:

 子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:\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

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

这篇关于code到从Access 2007年转移到Excel 2007中排除列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆