Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Excel print object?

5 views
Skip to first unread message

Robert Baer

unread,
Feb 7, 2020, 3:01:07 AM2/7/20
to
Snippet of incomplete program:
*COPY*
ActivePrinter = "Acrobat PDFWriter on FILE:": PrintToFile = True
'note need KILL statement for PDFWriter
' Above sets printer in Excel 2003; WILL crash in Excel 2010.

num = 1 'here we try to select the diagram only; hope printer will
use that
For Each iobj In ActiveSheet.Shapes 'DrawingObjects
iobj.Select
If num = 5 Then
Exit For 'got inserted "Picture 3"; want to print only this
End If
num = num + 1
Next iobj
' So..how do we pass it on?

' In "modern" defective Excel 2010, prints to default SO must set
default to what is needed
' ActivePrinter = "Xerox Phaser 6120 PS on FILE:": PrintToFile = True
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, _
Collate:=False, PrToFilename:=pPath + vNam 'use + ".PS" for Xerox
printer
Kill pPath + vNam 'not needed for PS printer
*END COPY*

So..how do we pass it on or select it or whatever for printing?

Thanks

Paul

unread,
Feb 7, 2020, 4:36:16 AM2/7/20
to
Did you go looking for example code ?

https://stackoverflow.com/questions/43259793/select-entire-sheets-for-printing-excel-vba

They present an overview of sorts about .select here.

Note that the HTML formatting applied here, may require you
to test multiple browsers to get a copy clean enough to read.
Seamonkey = screwy, Chromealike = OK.

https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba?rq=1

Paul

Robert Baer

unread,
Feb 7, 2020, 2:57:14 PM2/7/20
to
Well, i looked at those and others.
Everybody refers to ranges or cells or sheets or ...
BUT not at an actual object.
Using fake code, iobj.5 is also known as "Picture 3", which was
inserted from an external source.
The For Each iobj loop was the only way i discovered how to get at it.
I want to print it after i made changes by moving other objects into
and out of it.

Thanks

GS

unread,
Feb 8, 2020, 11:20:22 AM2/8/20
to
> Well, i looked at those and others.
> Everybody refers to ranges or cells or sheets or ...
> BUT not at an actual object.
> Using fake code, iobj.5 is also known as "Picture 3", which was inserted
> from an external source.
> The For Each iobj loop was the only way i discovered how to get at it.
> I want to print it after i made changes by moving other objects into and
> out of it.

When I modify/markup an image in Excel I take a ScreenCapture of it and convert
that to whatever image format I'm after. Since this is the only contents on a
worksheet, the normal Print processes work as expected for printing the
finished result.

Normally, I set the sheet up like graph paper and turn Gridlines off.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion

Robert Baer

unread,
Feb 9, 2020, 1:27:48 AM2/9/20
to
GS wrote:
>>   Well, i looked at those and others.
>>    Everybody refers to ranges or cells or sheets or ...
>>    BUT not at an actual object.
>>    Using fake code, iobj.5 is also known as "Picture 3", which was
>> inserted from an external source.
>>    The For Each iobj loop was the only way i discovered how to get at it.
>>    I want to print it after i made changes by moving other objects
>> into and out of it.
>
> When I modify/markup an image in Excel I take a ScreenCapture of it and
> convert that to whatever image format I'm after. Since this is the only
> contents on a worksheet, the normal Print processes work as expected for
> printing the finished result.
>
> Normally, I set the sheet up like graph paper and turn Gridlines off.
>
I have a loop around the basic generator to produce 200 patterns that
i want to save, and using a PDF printer to FILE: allows the computer to
do all of the work (like it should do).

Even for one pass, I cannot get it to print that object; so the
normal Print processes does NOT work properly; it prints the whole page.

Your last line indicates that you refer to sheets (like i said), not
an object/picture.

The For Each iobj loop selects the desired object(picture); how do i
complete the process to print it?

Thanks.



GS

unread,
Feb 9, 2020, 10:53:01 AM2/9/20
to
I ScreenCapture, as I said, then convert to the image format I want. There is
only 1 image per page, so if you want individual printouts then Insert >
PageBreak after each image.

Robert Baer

unread,
Feb 9, 2020, 5:30:47 PM2/9/20
to
Computers are supposed to be able to automate repetitive
(programming) tasks.
I create 200 different "Picture 3" (fifth iobj) and need to print
each one.
But i cannot print even one without code to do that.
For me to screen capture each one is manifestly stupid for me.

Do you have any clue as to what excel code to use for printing that
object?

Thanks.



Paul

unread,
Feb 9, 2020, 7:05:53 PM2/9/20
to
https://community.qlik.com/t5/New-to-QlikView/Export-sheetID-and-ObjectID-to-excel-file/m-p/19057

"Here is the script to export a list of sheets
and objects to a csv file for the current document."

[Note: when things are copied from websites like this, formatting
is frequently lost, and some corrections may be required because
of stuff that gets deleted]

LET vDocumentPath = DocumentPath();

SheetObject:

LOAD SheetId,

Title as SheetTitle,

%Key_Sheet_A4D568A6CD8BD40A

FROM [$(vDocumentPath)] (XmlSimple, Table is [DocumentSummary/Sheet]);

Left Join (SheetObject)

LOAD ObjectId%Table as ObjectId,

%Key_Sheet_A4D568A6CD8BD40A

FROM [$(vDocumentPath)] (XmlSimple, Table is [DocumentSummary/Sheet/ChildObjects/ObjectId]);

DROP Field %Key_Sheet_A4D568A6CD8BD40A;

Left Join (SheetObject)

LOAD ObjectId,

Caption as ObjectCaption,

Type as ObjectType

FROM [$(vDocumentPath)] (XmlSimple, Table is [DocumentSummary/SheetObject]);

STORE SheetObject INTO SheetObject.csv (txt);

*************************************************************

I have no idea what the significance of A4D568A6CD8BD40A is.
It's 128 bits and could be a GUID of some sort. But what it
points to, whether it's "random" or has a purpose, I haven't
a clue.

*******

I would think that a previous example I showed, where there
are a series of selectors such as a workbookID, a sheetID,
then objID, maybe you can make a uniform "looping over"
construct to select what you think is the same objID number
from each (incrementing) sheetID. That sort of thing.

*******

One other thing to remember, is docx or xlsx style things are
ZIP files. And you can try using 7ZIP to look inside. You
would not expect a "chart" to be a picture file, but for some
documents, if you imported pictures, the pictures stay intact
in the ZIP file and make it easier to repurpose them. Typically
all the pictures would be inside one folder inside the ZIP
in such cases.

https://www.7-zip.org/

Paul

GS

unread,
Feb 10, 2020, 12:13:58 AM2/10/20
to
> Computers are supposed to be able to automate repetitive (programming) tasks.
> I create 200 different "Picture 3" (fifth iobj) and need to print each
> one.
> But i cannot print even one without code to do that.
> For me to screen capture each one is manifestly stupid for me.
>
> Do you have any clue as to what excel code to use for printing that
> object?

What I do with ScreenCapture has nothing to do with what you want to do
print-wise. IF YOU PUT A PAGE BREAK AFTER EACH IMAGE as I suggested and use
normal print process, individual pages will be printed ONE IMAGE PER PAGE!

Robert Baer

unread,
Feb 11, 2020, 2:26:21 AM2/11/20
to
None of my objects are not sheets.
What looks "interesting" is:
LOAD ObjectId,
Caption as ObjectCaption,
Type as ObjectType
FROM [$(vDocumentPath)] (XmlSimple, Table is _
[DocumentSummary/SheetObject]);
STORE SheetObject INTO SheetObject.csv (txt);

Do not need spurious "caption", What i have IS an objecs by
definition so do not need to Type it.
Maybe ObjectID is "Picture 3".
No clue as what the heck [$(vDocumentPath)] is.
BUT the "FROM" may be useful to STORE SheetObject INTO ActivePrinter.

Will try fiddling that way.
Thanks.



Robert Baer

unread,
Feb 11, 2020, 2:29:10 AM2/11/20
to
GS wrote:
>> Computers are supposed to be able to automate repetitive (programming)
>> tasks.
>>    I create 200 different "Picture 3" (fifth iobj) and need to print
>> each one.
>>    But i cannot print even one without code to do that.
>>    For me to screen capture each one is manifestly stupid for me.
>>
>>    Do you have any clue as to what excel code to use for printing that
>> object?
>
> What I do with ScreenCapture has nothing to do with what you want to do
> print-wise. IF YOU PUT A PAGE BREAK AFTER EACH IMAGE as I suggested and
> use normal print process, individual pages will be printed ONE IMAGE PER
> PAGE!
>
One has to GET the image first. At present i have no way to transfer
the fifth iobj as an image to anything, so it is moot.

GS

unread,
Feb 12, 2020, 5:27:54 PM2/12/20
to
Not understanding your meaning here; - if the image is already on a worksheet
then just follow its position with a PageBreak so the normal printing process
outputs 1 image per page. Isn't this what you want?

Robert Baer

unread,
Feb 14, 2020, 1:49:43 AM2/14/20
to
GS wrote:
>> GS wrote:
>>>> Computers are supposed to be able to automate repetitive
>>>> (programming) tasks.
>>>>    I create 200 different "Picture 3" (fifth iobj) and need to print
>>>> each one.
>>>>    But i cannot print even one without code to do that.
>>>>    For me to screen capture each one is manifestly stupid for me.
>>>>
>>>>    Do you have any clue as to what excel code to use for printing
>>>> that object?
>>>
>>> What I do with ScreenCapture has nothing to do with what you want to
>>> do print-wise. IF YOU PUT A PAGE BREAK AFTER EACH IMAGE as I
>>> suggested and use normal print process, individual pages will be
>>> printed ONE IMAGE PER PAGE!
>>>
>>    One has to GET the image first. At present i have no way to
>> transfer the fifth iobj as an image to anything, so it is moot.
>
> Not understanding your meaning here; - if the image is already on a
> worksheet then just follow its position with a PageBreak so the normal
> printing process outputs 1 image per page. Isn't this what you want?
>
What is "follow its position"?
So far, there is no "normal printing process"; i do not know what
method or process or ... to use for printing.

GS

unread,
Feb 14, 2020, 12:43:56 PM2/14/20
to
Ok, assuming your image objects are on a worksheet and are oriented
top-to-bottom, the cell where the image object is inserted should also contain
a PageBreak so when you use Excel's Print process there will be one image
object per page. (You'll be able to see this in the PrintPreview pane)

Robert Baer

unread,
Feb 15, 2020, 1:59:59 AM2/15/20
to
There is only one object and it spans/covers a goodly number of
cells; it was inserted from a file, and takes space like a chart.
Therefore, a page break will have no effect - that would be behind
the image/picture.
And there is no "PrintPreview pane", never ever seen one in 7 years.

Stupid mmmmmmmm... what code is needed to print a chart?
Perhaps i could fumble that to print either the object or the
picture, since those are the same image.

Thanks.

GS

unread,
Feb 15, 2020, 5:21:48 AM2/15/20
to
Uh.., I've been using Excel since v4.0 and there has always been a PrintPreview
window (File > Print Preview) until v2007 when PrintPreview was included on the
Print tab of BackOffice, and now the File > Print tab in v2010 and later.
>
> Stupid mmmmmmmm... what code is needed to print a chart?
> Perhaps i could fumble that to print either the object or the picture,
> since those are the same image.
>
> Thanks.

You can't print objects themselves, just the portion of the sheet the objects
are on.

Paul

unread,
Feb 15, 2020, 11:08:42 AM2/15/20
to
Can you copy the items in question, into another Office tool like
MSWD and via OLE (object linking and embedding), print them when
in a Word document ? I can't believe printing the items by
themselves is useful. You probably want those objects plus
some descriptive text, for a re-purposing project.

Another way to do it, would be to print the whole thing to
PDF, and use LibreOffice Draw to read in the PDF, then
edit it as graphics and delete the stuff not wanted in
the picture. (Office 2003 likely doesn't read PDF,
while LO today can a bit.) Again, a poor way to do it,
not likely to look the way you wanted. Modern Office can
read in PDF.

And as for the topic of screen shots, the largest screenshot
I can do here, is 16384x16384 (in Linux). It's possible to
do that by editing Xorg.conf. It's not all that stable and
useful. You have to change the background of the screen and
"write stuff on it", to tell you where you are. Navigation
at 16384x16384 is almost impossible. Windows had
that capability too, up to a point. I found a claim
recently that the mode is now no longer possible/allowed
in Windows 10. The last OS "that isn't in chains" is
Windows 7. Windows 10 has had capabilities nibbled off
the edges, making it less useful for hero experiments
('cause everyone really wants a SmartPhone, right?).
Windows 7 is the last OS where FRAPS will run (an all purpose
screen capture utility).

Paul

Zaidy036

unread,
Feb 15, 2020, 11:15:04 AM2/15/20
to
"Page Layout" > "Page Setup" then small square with down/right arrow and
you will find PrintPreview

--
Zaidy036

GS

unread,
Feb 15, 2020, 11:51:29 AM2/15/20
to
If he puts PageBreaks in the appropriate places so the normal Print process
outputs 1 object per page it will do as he desires! Not sure why noone is
getting this; - perhap's it's just too simple?

Robert Baer

unread,
Feb 15, 2020, 12:15:12 PM2/15/20
to
Again, what code is needed to print a chart?

Robert Baer

unread,
Feb 15, 2020, 12:22:09 PM2/15/20
to
** So,you can automate (write program) to do all of the folowing 200 times?
* Page breaks will not show in a chart because a chart is "in front" or
overlays cells.
Furthermore, a chart can take a rather large number of cells (C6..Q38).

Again, what code is needed to print a chart?
>

GS

unread,
Feb 15, 2020, 2:31:44 PM2/15/20
to
> * Page breaks will not show in a chart because a chart is "in front" or
> overlays cells.

PageBreaks don't show at all; - they reside in the cell where they are
inserted!

> Furthermore, a chart can take a rather large number of cells (C6..Q38).
>
> Again, what code is needed to print a chart?

Again, you can't print a chart (or any other object) apart from its position on
the worksheet. *Excel only prints sheet contents in their respective location
on a sheet*

Zaidy036

unread,
Feb 15, 2020, 2:51:47 PM2/15/20
to

>>>    And there is no "PrintPreview pane", never ever seen one in 7 years.


>> "Page Layout" > "Page Setup" then small square with down/right arrow
>> and you will find PrintPreview
>>
>   Again, what code is needed to print a chart?

Nothing. Just responding to above in a previous post.
--
Zaidy036

Claus Busch

unread,
Feb 15, 2020, 3:19:38 PM2/15/20
to
Hi Garry,

Am Sat, 15 Feb 2020 14:31:38 -0500 schrieb GS:

> Again, you can't print a chart (or any other object) apart from its position on
> the worksheet. *Excel only prints sheet contents in their respective location
> on a sheet*

a chart is an exception. Select the chart => File => Print.
How to embed a shape into an empty chart object and then export that
chart object to a pdf file I wrote in public.excel.programming


Regards
Claus B.
--
Windows10
Office 2016

GS

unread,
Feb 15, 2020, 3:32:49 PM2/15/20
to
According to the Excel Object Browser, ChartObject does not have a Printout
method and so I suspect what's getting printed in your scenario is the range
the chart occupies on the sheet; - NOT the chart itself. Seems like a lot of
trouble to go to just to print a shape that will print in the normal process if
the PageSetup is done right!<g>

Robert Baer

unread,
Feb 15, 2020, 11:23:14 PM2/15/20
to
GS wrote:
>> * Page breaks will not show in a chart because a chart is "in front"
>> or overlays cells.
>
> PageBreaks don't show at all; - they reside in the cell where they are
> inserted!
>
>>    Furthermore, a chart can take a rather large number of cells
>> (C6..Q38).
>>
>>    Again, what code is needed to print a chart?
>
> Again, you can't print a chart (or any other object) apart from its
> position on the worksheet. *Excel only prints sheet contents in their
> respective location on a sheet*
* Not true; easy and simple when done manually:
1) Select the chart
2) File--> Print
Done.
>

Paul

unread,
Feb 16, 2020, 12:27:55 AM2/16/20
to

GS

unread,
Feb 16, 2020, 2:05:16 AM2/16/20
to
Wrong in the context you requested; - you can NOT duplicate that in VBA
otherwise you'd be able to create code via the Macro Recorder!

Using VBA, since that is the context of this thread, you must specify the range
the chart resides in to include it in a printout. Ergo, why I use PageBreak at
each insertion cell to get one object (chart,picture,shape) printed per page.
(Assumes all objects are within defined Print_Area)

Robert Baer

unread,
Feb 19, 2020, 11:19:17 PM2/19/20
to
No charts found; cannot work as-is.
If i change the word chart to shape i can find 16 shapes, which is
correct; it is the 4th shape, but one the activate crashes.
Then there is the problem of assigning a name to the print file.
Noodling around on that site was worse than not trying.
Tying the baby bird Goo-Gull,got nowhere.

Once upon a time, in one version of Excel,this worked:
ActivePrinter:="Acrobat PDFWriter", PrintToFile:= True, PrintToFile:=
True, _
PrintOut Copies:= 1, Preview:= False, Collate:= False, _
PrToFilename:=pPath + vNam + ".PDF"

Excel barfs.
Also, i was able to derive the above sequentially, comma to comma or
entry to entry from a pulldown in Excel - i think in edit.

No more; NO help even for ActivePrinter, were i started (i think).

Thanks.

Paul

unread,
Feb 20, 2020, 12:44:04 AM2/20/20
to
I tried to set myself up a trial version of Office 2003
to test, but that didn't work. Wouldn't activate.

What if you were to use the menus in Excel, to print the
entire document to PDF. So that you know all the
objects are in the document.

Then, use a PDF editor to re-arrange the content,
removing the parts you don't want.

You could try LibreOffice Draw as a PDF Editor of sorts.
Just print off one page as a test first, and experiment
with that.

Paul

Robert Baer

unread,
Feb 21, 2020, 2:39:30 AM2/21/20
to
I certainly do not want to do manual fiddling for each desired result
200 times!
Do not like the idea even for one result.

So far, the best i have squeezed out is initially set Print Area
C12..Q66, use my program to calculate and place shapes in iobj.3, STOP
program, manually file/print/name, then continue so program can then
"erase" the work to restore original inserted picture.

Good for onseies but far from ideal.
Would be VERY nice to have Excel do that manual part.....

Thanks.
0 new messages