Help with Code 
Author Message
 Help with Code

I have the following script that I am getting a unspecified error on the
line marked with **** when I run it.  Please help.  This code works with VB6
but not with VBScript.

Dim objWord
dim newButton
dim objCommandBar

Main

Sub Main ()
Set objWord = CreateObject("Word.Application")
Set objCommandBar = objWord.CommandBars("Formatting")

objWord.Visible = False
'msgbox "In Sub Main",vbokonly,"test"
    Set ctrls = objWord.CommandBars("Formatting").Controls
    For Each ctrl In ctrls
        If ctrl.ID = 1576 Then
            Exit Sub
        End If
    Next
    **** Set newButton = ctrls.Add(msoControlButton, 1576,1)
objWord.quit
End Sub



Wed, 19 Nov 2003 03:41:18 GMT  
 Help with Code
See what happens if you replace the constant "msoControlButton" with the
value 1.

Steve


Quote:
> I have the following script that I am getting a unspecified error on the
> line marked with **** when I run it.  Please help.  This code works with
VB6
> but not with vbscript.

> Dim objWord
> dim newButton
> dim objCommandBar

> Main

> Sub Main ()
> Set objWord = CreateObject("Word.Application")
> Set objCommandBar = objWord.CommandBars("Formatting")

> objWord.Visible = False
> 'msgbox "In Sub Main",vbokonly,"test"
>     Set ctrls = objWord.CommandBars("Formatting").Controls
>     For Each ctrl In ctrls
>         If ctrl.ID = 1576 Then
>             Exit Sub
>         End If
>     Next
>     **** Set newButton = ctrls.Add(msoControlButton, 1576,1)
> objWord.quit
> End Sub



Wed, 19 Nov 2003 05:03:03 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. HELP Error code 2244 & Error code 2465

2. Help with code to pull up .chm help file

3. FAO: Graham Mandeno - Or Anyone Can Help - Reusable Code

4. Help modify code for time format

5. Help with code

6. Help writing code

7. Need Help on Coding Syntax

8. Needed help for coding

9. Help with code

10. Help Writing Code/Module For An Excel Function

11. Help Optimizing Code

12. Help Using code in www.mvps.org API CALL to hide Access 97

 

 
Powered by phpBB® Forum Software