| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1690 人关注过本帖
标题:将计算结果输出到excel时出错,无法保存
只看楼主 加入收藏
彭林才
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2016-4-18
结帖率:66.67%
收藏
已结贴  问题点数:6 回复次数:1 
将计算结果输出到excel时出错,无法保存
将计算结果输出到excel时出错,代码如下
图片附件: 游客没有浏览图片的权限,请 登录注册

Set xlsApp = CreateObject("Excel.Application")
Set xlsworkbook = xlsApp.Workbooks.Open(App.Path & "\jieguo.xls")
xlsApp.Visible = False
Set xlssheet = xlsworkbook.Worksheets.Item(1)
xlssheet.Cells(1, 1) = "起算数据"
xlssheet.Cells(2, 1) = "已知点坐标"
xlssheet.Cells(3, 1) = "   点名   ": xlssheet.Cells(3, 2) = "    X(m)  ": xlssheet.Cells(3, 3) = "   Y(m)   "
If daoxianType = 1 Then
    For i = 1 To 4
        xlssheet.Cells(i + 3, 1) = yzdm(i): xlssheet.Cells(i + 3, 2) = yzzbx(i): xlssheet.Cells(i + 3, 3) = yzzby(i)
    Next
End If
If daoxianType = 0 Then
    For i = 1 To 2
        xlssheet.Cells(i + 3, 1) = yzdm(i): xlssheet.Cells(i + 3, 2) = yzzbx(i): xlssheet.Cells(i + 3, 3) = yzzby(i)
    Next
End If

xlsworkbook.Save
xlsApp.Quit
Set xlsApp = Nothing
 
搜索更多相关主题的帖子: excel 
2016-04-24 19:57
HVB6
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:15
帖 子:331
专家分:561
注 册:2013-10-30
收藏
得分:6 
试试:
Set xlsApp = CreateObject("Excel.Application")
Set xlsworkbook = xlsApp.Workbooks.Open(App.Path & "\jieguo.xls")
xlsApp.Visible = False
Set xlssheet = xlsworkbook.Worksheets.Item(1)
xlssheet.Cells(1, 1) = "起算数据"
xlssheet.Cells(2, 1) = "已知点坐标"
xlssheet.Cells(3, 1) = "   点名   ": xlssheet.Cells(3, 2) = "    X(m)  ": xlssheet.Cells(3, 3) = "   Y(m)   "
If daoxianType = 1 Then
    For i = 1 To 4
        xlssheet.Cells(i + 3, 1) = yzdm(i): xlssheet.Cells(i + 3, 2) = yzzbx(i): xlssheet.Cells(i + 3, 3) = yzzby(i)
    Next
End If
If daoxianType = 0 Then
    For i = 1 To 2
        xlssheet.Cells(i + 3, 1) = yzdm(i): xlssheet.Cells(i + 3, 2) = yzzbx(i): xlssheet.Cells(i + 3, 3) = yzzby(i)
    Next
End If
xlsApp.Visible = True
  xlsworkbook.Close (True)

'xlsworkbook.Save
xlsApp.Quit
Set xlsApp = Nothing
 
2016-04-25 10:25
快速回复:将计算结果输出到excel时出错,无法保存
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.043679 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved