运行时错误13:类型不匹配 [英] Run Time Error 13: Type Mismatch

查看:187
本文介绍了运行时错误13:类型不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 我在下面的代码中遇到问题,并且在粗体代码行上遇到类型不匹配错误: Private Sub CommandButton3_Click()
Application.ScreenUpdating = False
Dim p
Dim ActivePrinter
Dim Sheets

p = Application.ActivePrinter
ActivePrinter = (发送到OneNote 2010)

**表(Array(R-Overview,R-Savings,R-Table))PrintOut,,1 **

End Sub


解决方案

您无法创建/这样传递数组。尝试这个( TRIED AND TESTED

  Private Sub CommandButton3_Click()
Application.ScreenUpdating = False

Dim p
Dim ActivePrinter
Dim shtsArray(1 To 3)As String

p = Application.ActivePrinter
ActivePrinter =( 发送到OneNote 2010)

shtsArray(1)=R-Overview
shtsArray(2)=R-Savings
shtsArray(3)=R - 表

表(shtsArray).PrintOut,,1

Application.ScreenUpdating = True
End Sub

ONE MORE WAY

  Private Sub CommandButton3_Click()
Application.ScreenUpdating = False

Dim p
Dim ActivePrinter
Dim shtsArray
Dim sheetNames As String

p = Application.ActivePrinter
ActivePrinter =(发送到OneNote 2010)

sheetNames =R-Overview,R-Savings,R-Table
shts Array = Split(sheetNames,,)

表格(shtsArray).PrintOut,1
End Sub


I am having a problem with the following code and am getting a type mismatch error on the bolded line of code:

 Private Sub CommandButton3_Click()
     Application.ScreenUpdating = False
     Dim p
     Dim ActivePrinter
     Dim Sheets

     p = Application.ActivePrinter
     ActivePrinter = ("Send to OneNote 2010")

     **Sheets(Array("R-Overview", "R-Savings", "R-Table")).PrintOut , , 1**

  End Sub

解决方案

You cannot create/pass the array like this. Try this (TRIED AND TESTED)

Private Sub CommandButton3_Click()
    Application.ScreenUpdating = False

    Dim p
    Dim ActivePrinter
    Dim shtsArray(1 To 3) As String

    p = Application.ActivePrinter
    ActivePrinter = ("Send to OneNote 2010")

    shtsArray(1) = "R-Overview"
    shtsArray(2) = "R-Savings"
    shtsArray(3) = "R-Table"

    Sheets(shtsArray).PrintOut , , 1

    Application.ScreenUpdating = True
End Sub

ONE MORE WAY

Private Sub CommandButton3_Click()
    Application.ScreenUpdating = False

    Dim p
    Dim ActivePrinter
    Dim shtsArray
    Dim sheetNames As String

    p = Application.ActivePrinter
    ActivePrinter = ("Send to OneNote 2010")

    sheetNames = "R-Overview,R-Savings,R-Table"
    shtsArray = Split(sheetNames, ",")

    Sheets(shtsArray).PrintOut , , 1
End Sub

这篇关于运行时错误13:类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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