<form id="hbx9t"></form>

<noframes id="hbx9t">

    <em id="hbx9t"><span id="hbx9t"></span></em>

        <noframes id="hbx9t"><address id="hbx9t"><th id="hbx9t"><progress id="hbx9t"></progress></th></address>
        office交流網--QQ交流群號

        Access培訓群:792054000         Excel免費交流群群:686050929          Outlook交流群:221378704    

        Word交流群:218156588             PPT交流群:324131555

        Access中向Excel單元格中錄入數據

        2020-11-17 08:00:00
        tmtony8
        原創
        6326

        access常常需要和Excel表格交互數據。比如把access窗口中的文本寫入到Excel單元格中

        如圖所示,向單元格“B3”中輸入內容“office交流網”,點擊輸入到Excel表格中


        詳細代碼如下:主要是通過創建Excel對象,把指定內容錄入到指定的單元格中


            Dim xlApp As Object
            Dim xlWbk As Excel.Workbook
            Dim xlWsh As Excel.Worksheet
           
            
            Set xlApp = GetObject(, "Excel.Application")
            xlApp.Visible = True
            Set xlWbk = xlApp.Workbooks.Open(CurrentProject.Path & "\示例1.xlsx")
            Set xlWsh = xlWbk.Worksheets(1)
            xlWsh.Activate
           
            xlWsh.Range(txtRange).Value = Me.txt1 ' 
            
            xlWbk.Save '保存
            Set xlWsh = Nothing
            Set xlWbk = Nothing
            Set xlApp = Nothing



        效果如圖所示

          分享