在当前Word文档中查找表

时间:2018-04-23 19:51:18

标签: vba excel-vba excel

我尝试使用VBA编辑Word文档中的表格。即使文档中有多个表,以下MsgBox也会返回0。在宏的其他地方,我使用以下命令在Word文档中成功编辑了一个值:

With WA.ActiveDocument
Set myRange = .Content
With myRange.Find
.Execute Findtext:="Sally", ReplaceWith:=FirstName, Replace:=1
EndWith
EndWith
  

MsgBox(WA.ActiveDocument.Content.Tables.Count)

1 个答案:

答案 0 :(得分:0)

只需在With语句中使用(如果它们是实际表格)

Msgbox ActiveDocument.Tables.Count

您可以通过切换到Word文档本身并将以下Upload(file : File, id:number, endPoint:string) : void { const formData = new FormData(); formData.append(file.name, file); var auth = "Bearer " + this.Auth.GetAuth(); var autoThumb = this.stagedThumb == null ? 'true' : 'false'; const uploadRequest = new HttpRequest('POST', endPoint + `?id=${id}&thumb=${autoThumb}`, formData, { reportProgress: true, headers: new HttpHeaders({ 'Authorization': auth }) }); this.PerformUpload(uploadRequest); } PerformUpload(uploadRequest : HttpRequest<FormData>, progress: boolean = true) : void { this.http.request(uploadRequest).subscribe(event => { console.log("Http Event Message -- Progress: " + progress); console.log(event); console.log("End Event Message"); if (progress) { if (event.type == HttpEventType.UploadProgress) { this.progress = Math.round(100 * event.loaded / event.total); } else if (event.type == HttpEventType.Response) { this.message = event.body.toString(); setTimeout(() => { this.ResetForm(); }, 2*1000); } } }); } 放入ActiveDocument的ThisDocument部分来进行验证。如果答案仍为0,那么您不使用Word表格。