Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - how from VBA to VB Script

Reply
 
Old 05-22-2009   #1 (permalink)
aja74


 
 

how from VBA to VB Script

Hi,
I have VBA macro looking:
Workbooks.Open("C:\Excel1.xls")
Windows("Excel1.xls").Activate()
Range("A1").Select()
ActiveCell.FormulaR1C1 = "=LEFT('[Excel0.xls]dla HD'!C4,20)"
Range("A1").Select()
Selection.AutoFill(Destination:=Range("A1:A300"),
Type:=xlFillDefault)
Range("A1:A300").Select()
Windows("Excel1.xls").Activate()
ActiveWorkbook.Save()
Windows("Excel1.xls").Activate()
ActiveWindow.Close()

When in SSIS packages i put object Script task and put that code between
"Public Sub Main()" and "Dts.TaskResult..." and tried run macro i got few
errors.


Error 1 Name 'Workbooks' is not declared.
dts://Scripts/ScriptTask_6b69bf779c194352a1046a4bfb7ebefa/ScriptMain 29 9
ScriptTask_6b69bf779c194352a1046a4bfb7ebefa

Error 2 'System.Windows' is a namespace and cannot be used as an expression.
dts://Scripts/ScriptTask_6b69bf779c194352a1046a4bfb7ebefa/ScriptMain 31 9
ScriptTask_6b69bf779c194352a1046a4bfb7ebefa

Error 2 'System.Windows' is a namespace and cannot be used as an expression.
dts://Scripts/ScriptTask_6b69bf779c194352a1046a4bfb7ebefa/ScriptMain 31 9
ScriptTask_6b69bf779c194352a1046a4bfb7ebefa
...

How to do that VBA macro in this script editor?

AJA




My System SpecsSystem Spec
Old 05-22-2009   #2 (permalink)
Joe Fawcett


 
 

Re: how from VBA to VB Script

Basically your problems are not initialising some of the objects and using
named arguments, these aren't supported in VBScript.
I suggest you look at some of these examples on how to fix these issues:
http://www.activexperts.com/activmon...soffice/excel/


--

Joe Fawcett (MVP - XML)
http://joe.fawcett.name
"aja74" <ajanospam74@xxxxxx> wrote in message
news:gv5g7u$13e$1@xxxxxx
Quote:

> Hi,
> I have VBA macro looking:
> Workbooks.Open("C:\Excel1.xls")
> Windows("Excel1.xls").Activate()
> Range("A1").Select()
> ActiveCell.FormulaR1C1 = "=LEFT('[Excel0.xls]dla HD'!C4,20)"
> Range("A1").Select()
> Selection.AutoFill(Destination:=Range("A1:A300"),
> Type:=xlFillDefault)
> Range("A1:A300").Select()
> Windows("Excel1.xls").Activate()
> ActiveWorkbook.Save()
> Windows("Excel1.xls").Activate()
> ActiveWindow.Close()
>
> When in SSIS packages i put object Script task and put that code
> between
> "Public Sub Main()" and "Dts.TaskResult..." and tried run macro i got
> few
> errors.
>
>
> Error 1 Name 'Workbooks' is not declared.
> dts://Scripts/ScriptTask_6b69bf779c194352a1046a4bfb7ebefa/ScriptMain 29 9
> ScriptTask_6b69bf779c194352a1046a4bfb7ebefa
>
> Error 2 'System.Windows' is a namespace and cannot be used as an
> expression.
> dts://Scripts/ScriptTask_6b69bf779c194352a1046a4bfb7ebefa/ScriptMain 31 9
> ScriptTask_6b69bf779c194352a1046a4bfb7ebefa
>
> Error 2 'System.Windows' is a namespace and cannot be used as an
> expression.
> dts://Scripts/ScriptTask_6b69bf779c194352a1046a4bfb7ebefa/ScriptMain 31 9
> ScriptTask_6b69bf779c194352a1046a4bfb7ebefa
> ...
>
> How to do that VBA macro in this script editor?
>
> AJA
>
>
>


My System SpecsSystem Spec
Old 05-22-2009   #3 (permalink)
aja74


 
 

Re: how from VBA to VB Script

> Basically your problems are not initialising some of the objects and using
Quote:

> named arguments, these aren't supported in VBScript.
> I suggest you look at some of these examples on how to fix these issues:
> http://www.activexperts.com/activmon...soffice/excel/
Thank You.
Another question, when i have opened 2 excels, how to copy columns from one
to secound excel but from some columns make substring(column,1,10)

AJA




My System SpecsSystem Spec
Old 05-22-2009   #4 (permalink)
Paul Randall


 
 

Re: how from VBA to VB Script

In the scripting help file, script56.chm which is probably on your system
and downloadable through msdn.microsoft.com, through the contents tab, into
the VBScript Users Guide section, there are sections on VBScript features
not in VBA and VBA features not in VBScript. These should help your
understanding of the problem.

-Paul Randall

"aja74" <ajanospam74@xxxxxx> wrote in message
news:gv5g7u$13e$1@xxxxxx
Quote:

> Hi,
> I have VBA macro looking:
> Workbooks.Open("C:\Excel1.xls")
> Windows("Excel1.xls").Activate()
> Range("A1").Select()
> ActiveCell.FormulaR1C1 = "=LEFT('[Excel0.xls]dla HD'!C4,20)"
> Range("A1").Select()
> Selection.AutoFill(Destination:=Range("A1:A300"),
> Type:=xlFillDefault)
> Range("A1:A300").Select()
> Windows("Excel1.xls").Activate()
> ActiveWorkbook.Save()
> Windows("Excel1.xls").Activate()
> ActiveWindow.Close()
>
> When in SSIS packages i put object Script task and put that code
> between
> "Public Sub Main()" and "Dts.TaskResult..." and tried run macro i got
> few
> errors.
>
>
> Error 1 Name 'Workbooks' is not declared.
> dts://Scripts/ScriptTask_6b69bf779c194352a1046a4bfb7ebefa/ScriptMain 29 9
> ScriptTask_6b69bf779c194352a1046a4bfb7ebefa
>
> Error 2 'System.Windows' is a namespace and cannot be used as an
> expression.
> dts://Scripts/ScriptTask_6b69bf779c194352a1046a4bfb7ebefa/ScriptMain 31 9
> ScriptTask_6b69bf779c194352a1046a4bfb7ebefa
>
> Error 2 'System.Windows' is a namespace and cannot be used as an
> expression.
> dts://Scripts/ScriptTask_6b69bf779c194352a1046a4bfb7ebefa/ScriptMain 31 9
> ScriptTask_6b69bf779c194352a1046a4bfb7ebefa
> ...
>
> How to do that VBA macro in this script editor?
>
> AJA
>
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Logon Script Causing Laptops To Hang - Problems in script? VB Script
problem passing args to script 'There is no script engine for file extenstion' VB Script
Include another script, keep variables in included script? PowerShell
Script file has 'OS Handle' error when run from script PowerShell
Can you drag-n-drop a file on top of a PS script to run the script? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46