English 中文(简体)
从Excel到Word的制版和删除图
原标题:Copying and Deleting charts from Excel to Word

My ultimate goal is to be able copy charts from Excel worksheets (16 in all), and paste them into a Word document at known bookmarks, Inline with the text. I do not want the Word file to link to the Spreadsheet for reasons I won t go into here. I then need to be able delete these same charts later on before copying a new set into the document.

看来,诺言中的InLineShapes没有“Name”财产,只是一个指数,我认为该指数必须是“长”而不是“ger”。 当我点击我所复制的一张图表时,我用Edit>Sengon在Word Ribbon使用,我确实把每个图表的国名显示为图1等。

目前,我使用Excel工作手册中的以下编码,复制和将图表编成“言语”,似乎可以做些细。

This code will use Bookmarks to place the charts and copy them from this Workbook

        For i = 1 To 16

            Sheets(sheetnames(i)).Select
            ActiveSheet.ChartObjects(Chartlocn(i)).Activate
            ActiveChart.ChartArea.Copy
            

            With d.Bookmarks(Bookmarklocn(i)).Range
        
                .Select
                objW.Selection.PasteSpecial Link:=False, DataType:=15, Placement:=wdInLine, _
                DisplayAsIcon:=False
               
       
            End With
    
        Next i

我已尝试使用以下代码删除图表:

 j = d.InlineShapes.Count
                
        counter = 0
        For i = 1 To d.InlineShapes.Count
    
            counter = counter + 1
            MsgBox (i)
            
                
             If d.InlineShapes.Item(counter).Type = _
                 wdInlineShapePicture Then
                d.InlineShapes.Item(counter).Select
                objW.Selection.Delete Unit:=wdCharacter, Count:=1   Came from Macro Recording
                
             Else
             End If
            
        Next i

上文评论的标语对我没有用处。

Despite checking everything I could imagine in the word file and Excel workbooks, each chart seems to be the same - all inline, all sequentially "names" Picture x, same method to copy and paste.

但所观察到的行为是,一些图表被删除,有些则没有。

是否有某种机制以某种方式确定图表,然后予以删除。 我知道,他们在书记处已经过去。 我没有明显的东西,也没有更好的复制和跟踪方法,因此我可以“以某些名字或身份识别符号来”他们?

最佳回答

如果你们都想删除使用<代码”的现成文件内的所有图表。 关于,你可能需要从最高指数开始。

For i = d.InlineShapes.Count to 1 Step -1

但是,仅仅使用<条码”更简单、更好。 每一条

例如:

Dim WordApp As Word.Application
Set WordApp = GetObject(, "Word.Application")

Dim chrt As Word.InlineShape
For Each chrt In WordApp.ActiveDocument.InlineShapes
    chrt.Delete
Next

关于获得某种识别标志以特定图表为目标的问题,我个人希望使用<代码>的备选<>/代码>,如果你将图表复制到Word,则该财产保持不变。

问题回答

暂无回答




相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签