Sign in to follow this  
Followers 0
Hardnik

excel macro run

4 posts in this topic

hello please help to translate this vbs script in the format of autoit

Dim objXL
Set objXL = WScript.CreateObject("Excel.Application")
objXL.Visible = false
objXL.Workbooks.Open ("\\file\bin$\dev\forum.xls")
Set modAdd = objXL.Workbooks.Open("\\file\bin$\PRICE.xla")
objXL.Run modAdd.Name & "!price.price"
objXL.Run modAdd.Name & "!Price.hide"
objXL.DisplayAlerts = False
objXL.ActiveWorkbook.SaveAs "\\file\bin$\dev\price.xls"
objXL.Workbooks.Close
objXL.DisplayAlerts = True
objXL.Quit

beforehand thank you

Share this post


Link to post
Share on other sites



hello please help to translate this vbs script in the format of autoit

Dim objXL
Set objXL = WScript.CreateObject("Excel.Application")
objXL.Visible = false
objXL.Workbooks.Open ("\\file\bin$\dev\forum.xls")
Set modAdd = objXL.Workbooks.Open("\\file\bin$\PRICE.xla")
objXL.Run modAdd.Name & "!price.price"
objXL.Run modAdd.Name & "!Price.hide"
objXL.DisplayAlerts = False
objXL.ActiveWorkbook.SaveAs "\\file\bin$\dev\price.xls"
objXL.Workbooks.Close
objXL.DisplayAlerts = True
objXL.Quit

beforehand thank you

1. Take all the "Set" commands out, AutoIt doesn't need "Set" to do assignment.

2. Put a dollar sign "$" in front of every instance of the objXL and $modAdd variables.

3. Put parameters inside parens, i.e. objXL.Run(modAdd.Name & "!price.price")

Like the Water Boy, "You can do it!"

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

at the use of code there is an error in ecxel with an original vbs script all is normal

error:

in scite:
\\file\bin$\price.au3 (62) : ==> The requested action with this object has failed.: 
$objXL.Run($modAdd.Name & "!price.price") 
$objXL.Run($modAdd.Name & "!price.price")^ ERROR

in excel:
Run-time error '1004':
it is impossible to set property of NumberFormat of class of Range

Dim $objXL
Dim $modAdd
$objXL = ObjCreate("Excel.Application")
$objXL.Visible = false
$objXL.Workbooks.Open ("\\file\bin$\dev\forum.xls")
$modAdd = $objXL.Workbooks.Open("\\file\bin$\PRICE.xla")
$objXL.Run($modAdd.Name & "!price.price");error in this place
$objXL.Run($modAdd.Name & "!Price.hide")
$objXL.DisplayAlerts = False
$objXL.ActiveWorkbook.SaveAs("\\file\bin$\dev\price.xls")
$objXL.Workbooks.Close
$objXL.DisplayAlerts = True
$objXL.Quit

p.s. please will excuse if talk wrong utillize translator

Edited by Hardnik

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

at the use of code there is an error in ecxel with an original vbs script all is normal

error:

in scite:
\\file\bin$\price.au3 (62) : ==> The requested action with this object has failed.: 
$objXL.Run($modAdd.Name & "!price.price") 
$objXL.Run($modAdd.Name & "!price.price")^ ERROR

in excel:
Run-time error '1004':
it is impossible to set property of NumberFormat of class of Range

p.s. please will excuse if talk wrong utillize translator

You translated the VBScript to AutoIt exactly as I would have. The strange thing is that error seems to come from an error inside the macro, not in the script code.

Unfortunately, without the .xls and .xla files including the macros, I don't see how to debug further.

:)

P.S. Are those paths correct at "\\file\bin$\dev\forum.xls" and "\\file\bin$\PRICE.xla"? There is a UNC path to a file server called "file" with a share called "bin$", etc.? I am asking because I wonder if they are interpreted differently in VBScript. Doesn't seem likely, but can be tested by adding this where you are opening the files:

Dim $sXLS = "\\file\bin$\dev\forum.xls"
Dim $sXLA = "\\file\bin$\PRICE.xla"
If FileExists($sXLS) And FileExists($sXLA) Then
    $objXL.Workbooks.Open ($sXLS)
    $modAdd = $objXL.Workbooks.Open($sXLA)
Else
    MsgBox(16, "Error", "At least one file not found!")
    Exit
EndIf
Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  
Followers 0