From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programatically call the function "fit to paper" and use it Excel worksheet before printing?

Solved!
Go to solution

Hello all,

I want to print a report using Excel worksheet functions. I've already managed to change height, width of columns, alignment

of cells, but I still haven't find how to fit the current worksheet to the selected size of paper.

 

Does someone knows if this is possible? You see in excel or word when you're about to print, there's an option called

"fit to paper"; this option comes in handy when the Excel file has lots of column and you want print that, using only

1 page, not matter the size of the font size (as longs as it's readable)

 

Im attaching the block diagram of my current VI.

 

For what I want do I have to call the ActivEx functions?

 

Please any advice!!

0 Kudos
Message 1 of 8
(4,791 Views)
Solution
Accepted by topic author JLuna

Use Excel Get ActiveX References and wire the references to access ActiveX properties that aren't exposed by the Report Generation VIs.

 

Excel Print.png

Feel free. Contact me for anything more,
    Pang

You too can be LabVIEW Awesome!
Message 2 of 8
(4,767 Views)

Just one question. What does numeric number "1" does in the method PAGE SETUP? Before running the VI, I had the zoom in TRUE and I had an error in screen also. Could you explain me this two little details? I want to start using more ACTIVEX, seems that these functions are highly useful.

Do you know any literature that I could use to learn more about using ACTIVEX in LabVIEW??

 

Many, many thanks for you help!!!

 

I attached the image with the error, when using TRUE in ZOOM input.

0 Kudos
Message 3 of 8
(4,737 Views)

I believe "1" represents the number of pages your sheet will print to. I took the values from Microsoft's help pages:

 

FitToPagesTall

FitToPagesWide

Zoom

 

Based on the documentation for Zoom:

If this property is False, the FitToPagesWide and FitToPagesTall properties control how the worksheet is scaled.

 

Look here for info on calling ActiveX objects in LabVIEW:

 

http://zone.ni.com/reference/en-XX/help/371361N-01/lvconcepts/using_activex_with_labview/

 

The steps boil down to opening a reference and calling properties or methods provided by the ActiveX object.

Feel free. Contact me for anything more,
    Pang

You too can be LabVIEW Awesome!
Message 4 of 8
(4,731 Views)

Thanks for your help, I really appreciate your time.

0 Kudos
Message 5 of 8
(4,725 Views)

Next time you need to implement an ActiveX function that you know exists in Excel, but don't know where to find, here is a trick.

1. Open Excel

2. Record a macro

3. Manually make the change to the workbook

4. Stop the macro

5. View the code

 

This will reveal the exact syntax and object hierarchy needed in LabVIEW to make the same function.  If you know the function name, you can also search the Excel Visual Basic for Applications window using the object browser.  Attached is the macro generated by setting the Fit to 1x1.

Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.0, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
Message 6 of 8
(4,698 Views)

Thanks for the advice man!! \m/

0 Kudos
Message 7 of 8
(4,647 Views)

@pangvady wrote:

I believe "1" represents the number of pages your sheet will print to. I took the values from Microsoft's help pages:

 


It sets the number of pages tall or wide to which the worksheet will be scaled when it's printed (according your worksheet is tall or wide enough to cover these amount of pages, if you have a single column it will not print 2 pages wide).

Ben64

0 Kudos
Message 8 of 8
(4,630 Views)