Jump to content
Sign in to follow this  
nicky40

Any help for the n00bs?

Recommended Posts

nicky40

Hey guys, I'm trying to make a really simple script utilizing the Excel.AU3 documentation.

CODE
#include <Excel.au3>

Global $sXLS = "C:\StartingPoint1.xls"

Global $oExcel = _ExcelBookOpen($sXLS)

_ExcelSheetActivate($oExcel, "sheet1")

_ExcelWriteCell($oExcel, "File Name", "A5")

_ExcelBookClose($oExcel, 1, 0)

The script completes w/out crashing, but there is no file alterations.

I've also tried the:

CODE
_ExcelBookSaveAs($oExcel, @ScriptDir & "\SaveAsExample", "xls")

Still no luck.

Thanks,

Nicholas

Share this post


Link to post
Share on other sites
nicky40

And like my previous posts, I'm willing to paypal donate to whoever helps!

Share this post


Link to post
Share on other sites
theAutoitSpammer

Your script works for me ;)

I had a similar problem with an excel function, the solution was 'registry cleaning'

I don't think offering money is a good idea, we all do it for fun, if we can help we will. ^_^

Al

And like my previous posts, I'm willing to paypal donate to whoever helps!

Edited by alram

Share this post


Link to post
Share on other sites
nicky40

Your script works for me ;)

I had a similar problem with an excel function, the solution was 'registry cleaning'

I don't think offering money is a good idea, we all do it for fun, if we can help we will. ^_^

Al

It edits the excel file and saves it?! I don't understand why it won't work on my system. grr :?

Share this post


Link to post
Share on other sites
theAutoitSpammer

I insert a 1 sec sleep before close and worked, then I delete

the sleep and still worked.

Like I said a registry cleaning worked for me.

Is the "C:\StartingPoint1.xls" file exists??

if this solution works, please mark your original post as [sOLVED]

It edits the excel file and saves it?! I don't understand why it won't work on my system. grr :?

Edited by alram

Share this post


Link to post
Share on other sites
nicky40

I insert a 1 sec sleep before close and worked, then I delete

the sleep and still worked.

Like I said a registry cleaning worked for me

if this solution works, please mark your original post as [sOLVED]

What cleaner did you use? I'd be much appreciative if you could share the name!

Share this post


Link to post
Share on other sites
theAutoitSpammer

I use Registry Mechanic but there are many more for free

Caution---please understand that messing with the registry could be dangerous

I would learn as much as possible before doing it.

What cleaner did you use? I'd be much appreciative if you could share the name!

Share this post


Link to post
Share on other sites
nicky40

I use Registry Mechanic but there are many more for free

Caution---please understand that messing with the registry could be dangerous

I would learn as much as possible before doing it.

Didn't work, I'm not sure this would have fixed the issue. You can confirm this works on your system?

Anybody else out there able to test something like this?

Share this post


Link to post
Share on other sites
Juvigy

Which version of excel do you have ? You need to enable some settings :

Try this one :

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security", "AccessVBOM", "REG_DWORD", 1)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security", "AccessVBOM", "REG_DWORD", 1)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security", "ExtensionHardening", "REG_DWORD", 0)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security", "ExtensionHardening", "REG_DWORD", 0)

They are for 2007 and 2003 versions

Share this post


Link to post
Share on other sites
nicky40

Which version of excel do you have ? You need to enable some settings :

Try this one :

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security", "AccessVBOM", "REG_DWORD", 1)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security", "AccessVBOM", "REG_DWORD", 1)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security", "ExtensionHardening", "REG_DWORD", 0)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security", "ExtensionHardening", "REG_DWORD", 0)

They are for 2007 and 2003 versions

I'm on 2007, I'm not really familar with RegWrite, would you mind giving a short explanation?

Thanks,

Nicholas

Share this post


Link to post
Share on other sites
nicky40

Which version of excel do you have ? You need to enable some settings :

Try this one :

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security", "AccessVBOM", "REG_DWORD", 1)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security", "AccessVBOM", "REG_DWORD", 1)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security", "ExtensionHardening", "REG_DWORD", 0)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security", "ExtensionHardening", "REG_DWORD", 0)

They are for 2007 and 2003 versions

Dropped them into my script, and still no dice, I have to be doing something fundamentally wrong.

Share this post


Link to post
Share on other sites
Juvigy

This lines writes to the registry. This enables the Excel to trust access to Visual Basic. As i think about it now it is more related to VB scripts but i am not sure if it has impact on the Excel object model. Please try it and see if it works.You can skip the :

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security", "AccessVBOM", "REG_DWORD", 1)

It is for 2003.

Share this post


Link to post
Share on other sites
nicky40

This lines writes to the registry. This enables the Excel to trust access to Visual Basic. As i think about it now it is more related to VB scripts but i am not sure if it has impact on the Excel object model. Please try it and see if it works.You can skip the :

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security", "AccessVBOM", "REG_DWORD", 1)

It is for 2003.

I must have posted right before you, but I tried and still nothing, I'm thinking for something is wrong funamentally in my script.

Share this post


Link to post
Share on other sites
Juvigy

it forks for me too.

Global $sXLS = "C:\StartingPoint1.xls"

Global $oExcel = _ExcelBookOpen($sXLS

Does StartingPoint1.xls exist in c:\ ?

#include <Excel.au3>

Global $sXLS = "C:\123.xls"

Global $oExcel = _ExcelBookOpen($sXLS)

_ExcelSheetActivate($oExcel, "sheet1")

_ExcelWriteCell($oExcel, "File Name", "A5")

_ExcelBookClose($oExcel, 1, 0)

Try this one. But fist create a new Excel file called 123.xls in C drive

Edited by Juvigy

Share this post


Link to post
Share on other sites
nicky40

Yeah tried that version, and still no result. I guess it's my local computer?

it forks for me too.

Global $sXLS = "C:\StartingPoint1.xls"

Global $oExcel = _ExcelBookOpen($sXLS

Does StartingPoint1.xls exist in c:\ ?

#include <Excel.au3>

Global $sXLS = "C:\123.xls"

Global $oExcel = _ExcelBookOpen($sXLS)

_ExcelSheetActivate($oExcel, "sheet1")

_ExcelWriteCell($oExcel, "File Name", "A5")

_ExcelBookClose($oExcel, 1, 0)

Try this one. But fist create a new Excel file called 123.xls in C drive

Share this post


Link to post
Share on other sites
theAutoitSpammer

EXCEL 2007 SAVES FILES AS 123.XLSX WHEN NOT IN COMPATIBILITY MODE

AND YOUR SCRIPT IS TRYING TO LOAD A 123.XLS

COULD THAT BE YOUR PROBLEM? ^_^

Share this post


Link to post
Share on other sites
nicky40

EXCEL 2007 SAVES FILES AS 123.XLSX WHEN NOT IN COMPATIBILITY MODE

AND YOUR SCRIPT IS TRYING TO LOAD A 123.XLS

COULD THAT BE YOUR PROBLEM? ^_^

<3 Thank you sir/maime. This solved my problem, thank you so much.

Share this post


Link to post
Share on other sites
theAutoitSpammer

<3 Thank you sir/maime. This solved my problem, thank you so much.

Happy to hear it. ^_^

Please mark your original post with [sOLVED] or [RESOLVED]

Al

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.