SiJoong Song
Posts: 2
Joined: 2019-11-11
|
In MS-WORD
-When copying a sentence, the message 'cannot open clipboard' is displayed intermittently.
-When copying a picture, in most cases the picture is not copied to the clipboard, and no error occurs.
(Also, when checking if there is any BITMAP information on the clipboard, TRUE is returned in most cases.)
windows10 can see clipboard when WinKey+V.
**** These problems are not seen at all when testing with an EXE made by same code.
Appears only when running as an addin for MS-WORD using Addin Express.
what can i try for fix thiese problems??
I am currently using Windows 10 64bit, MS-WORD 2007 32bit.
For reference, the routine to copy a picture is as follows:
// i had set MS-WORD OLE to 'MSWDocument'
Selection := MSWDocument.ActiveDocument.ActiveWindow.Selection;
Shapes := Selection.InlineShapes;
if Shapes.Count > 0 then
begin
Shapes.Item(1).Select;
MSWDocument.ActiveDocument.ActiveWindow.Selection.Copy;
// if ADDIN, most case no image exist on clipboard.
if ClipBoard.HasFormat(CF_BITMAP) = True then
result := True;
end; |
|
Andrei Smolin
Add-in Express team
Posts: 19100
Joined: 2006-05-11
|
|
SiJoong Song
Posts: 2
Joined: 2019-11-11
|
Hi. Andrei Smolin.
sample was wrong.
i have check sample you linked.
this sample can not copy picture, always.
there are if shapes.Count > 0 then begin |
if shapes.Count > 0 then begin
but 'shapes.Count' always 0.
(sure, my test document have 2 images)
i try 'Shapes' change to 'InlineShapes' then i can count.
(and some more modify)
var | shapes: Word2000.InlineShapes; | selection: Word2000.WordSelection; | begin | selection := WordApp.ActiveWindow.Selection; | if Assigned(selection) then begin | shapes := WordApp.ActiveDocument.InlineShapes; | if Assigned(shapes) then begin | if shapes.Count > 0 then begin | shapes.Item(1).Select; | selection.Copy; | | Shapes.item(1).Delete; | selection.Paste; | end; | shapes := nil; | end; | selection := nil; | end; | end; |
var
shapes: Word2000.InlineShapes;
selection: Word2000.WordSelection;
begin
selection := WordApp.ActiveWindow.Selection;
if Assigned(selection) then begin
shapes := WordApp.ActiveDocument.InlineShapes;
if Assigned(shapes) then begin
if shapes.Count > 0 then begin
shapes.Item(1).Select;
selection.Copy;
// delete & paste for test
Shapes.item(1).Delete;
selection.Paste;
end;
shapes := nil;
end;
selection := nil;
end;
end;
when i run modify-code at ADX OnClick event, copy was successful on PC.
(if run on VMWare virtual-machine then sometime success, sometime fail)
but my original program still not copy.
my original code is in a different UNIT and is called from a long routine.
I suspect ADX affects the clipboard. because my EXE always success.
Is there anything that could affect the clipboard? |
|
Andrei Smolin
Add-in Express team
Posts: 19100
Joined: 2006-05-11
|
Hello SiJoong,
SiJoong Song writes:
i try 'Shapes' change to 'InlineShapes' then i can count.
Shapes and InlineShapes are different collections containing different (although very similar) objects. That is, your test documents contain Inlineshape objects, not Shape.
SiJoong Song writes:
my original code is in a different UNIT and is called from a long routine.
We suppose that your long routine takes part in this issue. In the general case, such a routine may be called in a context (or it may create a context) that isn't suitable for copying anything to the Clipboard.
SiJoong Song writes:
I suspect ADX affects the clipboard.
Add-in Express doesn't use/handle/whatever the Clipboard. To check this, add a test Ribbon button and execute your Clipboard-related code.
Andrei Smolin
Add-in Express Team Leader |
|