Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在vba环境之外编译问题_Vba_Ms Word_Windows Scripting - Fatal编程技术网

在vba环境之外编译问题

在vba环境之外编译问题,vba,ms-word,windows-scripting,Vba,Ms Word,Windows Scripting,我有以下代码: Sub vbRemoveSpacing() Dim doc As Document Set doc = Documents.Open("C:/Document.docx") For Each tbl In doc.Tables With tbl With .Range.ParagraphFormat .SpaceBefore = 0 .SpaceBef

我有以下代码:

Sub vbRemoveSpacing()

    Dim doc As Document
    Set doc = Documents.Open("C:/Document.docx")
    For Each tbl In doc.Tables
        With tbl
            With .Range.ParagraphFormat
                .SpaceBefore = 0
                .SpaceBeforeAuto = F
                .SpaceAfter = 0
                .SpaceAfterAuto = F
            End With
            .Rows.SetHeight RowHeight:=0.1, HeightRule:=wdRowHeightAtLeast
        End With
    Next

    doc.Close (True)
End Sub
我希望能够从.vbs文件运行它。将其复制到.vbs文件中并运行会出现错误

线路:3 字符:13 错误:应为语句结尾


即使删除这行代码,以后也会返回类似的错误,
.Rows.SetHeight…
也会出现类似的问题。出了什么问题?

我不确定Rows.SetHeight的问题,但第3行的错误是因为-没有
作为
关键字:

Dim doc
Set doc = ...

我不确定Rows.SetHeight的问题,但第3行的错误是因为-没有
As
关键字:

Dim doc
Set doc = ...

VBA到vbscript不是这样工作的:您必须进行一些更改请参见:和/或使用
Dim doc
而不是
Dim doc As Document
,vbscript中的变量声明中没有
As
关键字。顺便说一句,所有其他变量声明在哪里?
Set Doc=CreateObject(“Word.Document”)
VBS中只允许后期绑定。或者出于您的目的
设置Doc=GetObject(“C:\Document.docx”)
(I固定路径分隔符)。在help@omegastripes中查找它们,没有其他变量。那么tbl是什么,如果不是变量的话?VBA到vbscript不是这样工作的:您必须进行一些更改请参见:和/或使用
Dim doc
而不是
Dim doc As Document
,vbscript中变量声明中没有
As
关键字。顺便说一句,所有其他变量声明在哪里?
Set Doc=CreateObject(“Word.Document”)
VBS中只允许后期绑定。或者出于您的目的
设置Doc=GetObject(“C:\Document.docx”)
(I固定路径分隔符)。在help@omegastripes中查找它们,没有其他变量。那么tbl是什么,如果不是变量的话?@alowflyingpig什么?@alowflyingpig什么?