Jump to content
Sign in to follow this  
Xenobiologist

_ExcelBookOpen 2007 xlsm file (print area gets lost)

Recommended Posts

Xenobiologist

Hi @all,

I'm working on a little Autoit script which opens a .xlsm file and does something with it.

I recently recognized that opening the file via Autoit (Excel UDF) has bad impact on the print area.

The predefined print area gets lost.

Anybody an idea how to avoid that?

#include <Excel.au3>
$sFilePath1 = @ScriptDir & "\test.xlsm" ;This file should already exist
$oExcel = _ExcelBookOpen($sFilePath1)
If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist - Shame on you!")
    Exit
EndIf

If you open the test.xlsm with the script the print area is set to a1:a3

If you open the test.xlsm with the script via shellexecute or whatsoever, the print area is a1:e13

There is no marco in this test file!

Mega

Test.zip

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
Xenobiologist

I know, the thread is not even 24 hours open, but it is a little bit urgend. :graduated:

Somebody who can at least confirm the probelm with Excel.au3 opening a xlsm file with a predefined print area?

Thanks!


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
bogQ

2007 and 2003 is a1:e13 with autoit or with double click on file, they gave identical mark results in print area after print preview.

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites
Xenobiologist

You mean, you opened the file with _ExcelBookOpen and the print area was the same as when you opened it via double click or shellexecute?

The problem is the function from Excel.au3 (creating the excel obj) not Shellexecute or something else.

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
bogQ

yes i opened it with your script that you posed, and after that i opened it via double click, i got identical results on 2007 and after that i tested it on 2003 with identical results.

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites
Xenobiologist

That's weird! I have to co-workers testing the issue. Both of them and of course me too have the problem.

Maybe it belongs to the German Excel version. I don't know.

I'm using 12.0.6565.5003 SP2 of Excel 2007 on a WIN XP SP3 32 bit machine .

Thanks for testing!


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
Juvigy

Maybe it is related to excel options . Try setting the print area from Autoit :

$oExcel.Range("A1:E20").Select

$oExcel.Application.Activesheet.Pagesetup.PrintArea = $oExcel.Selection.Address

Share this post


Link to post
Share on other sites
Xenobiologist

Hm, what option do you mean?

Setting the print area is no option more me, because the script is part of a deployment process of IBM Cognos reports (Go!Office).

That means there are tons of reports to deploy. I don't know the print areas of them and I don't want to hard-code them.

If I open the file via Excel UDF I cannot grab the prtint area, because it is has already been changed by ... :graduated: whatever.

(Besides, I have a solution without Excel.au3 yet, but it is not very nice looking. (Too much Sends and so on)

However, it seems to work, but it would be better with Excel UDF.


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
Juvigy

Well it can be cell R1C1 references , security settings or other settings that remove the print area. If you can test - reset to default settings and try again.

Share this post


Link to post
Share on other sites
Xenobiologist

Okay, I'll give it a try. Besides, I have asked in the German autoit.de-forum as well.

Confirmation, that the print area changes via Excel.au3.


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×