newbie question - trying to start applications with .vbs file 
Author Message
 newbie question - trying to start applications with .vbs file

Hi there, I'm quite new to using VBScript, but anyways, I'm trying to create a
little script that will pop up a list of applications and start the one chosen
by a input box entry.

My question / problem is, with some applications (like word, powerpoint) you can
just open up the application without needing to specify a file, and the
application appears without a 'document', but with Excel and Project, I seem to
need to specify a 'document' - adding new workbook or project.  I guess the
first part of my question is, "is there a way to start excel and project without
adding a dummy workbook/project? - how?"

The second part of my question is can I do the same with MS access (start up
without a dummy database), or if not, what is the equivalent step(s) that I need
to include to bring up MSAccess.  I tried the following script file (office.vbs)
and when I chose option 5 (MS Access) a window VERY briefly flickers on the
screen, then nothing, and then if I check in the temp directory there is a
database1.mdb there.

TIA
-------------------------------------------------------
Please reply to the group
-------------------------------------------------------

do
choicematrix = "1 - Excel"
choicematrix = choicematrix & chr(13) & "2 - Word"
choicematrix = choicematrix & chr(13) & "3 - Project"
choicematrix = choicematrix & chr(13) & "4 - PowerPoint"
choicematrix = choicematrix & chr(13) & "5 - Access"
reply = inputbox(choicematrix, "Choose Which MSOffice Program to Start", 0)
flip = vbcancel
if reply = 1 then
set startApp = createobject("Excel.application")
startapp.Workbooks.Add
elseif reply = 2 then
set startapp = createobject("Word.application")
elseif reply = 3 then
set startapp = createobject("MSProject.application")
startapp.projects.add
elseif reply = 4 then
set startapp = createobject("PowerPoint.application")
elseif reply = 5 then
set startapp = createobject("Access.application")
startapp.createaccessproject("C:\temp\Database1.mdb")
ElseIf Reply = "" Then
Flip = vbCancel
else
flip = msgbox( "You didn't make a valid selection", vbokcancel, "MSOffice
Selector")
end if
loop while flip<>vbcancel

if reply <>0 and reply<6  then
startapp.visible = true
end if



Sat, 16 Jul 2005 22:56:14 GMT  
 newbie question - trying to start applications with .vbs file

Quote:
> ...  I guess the first part of my
> question is, "is there a way to start excel and project without
> adding a dummy workbook/project? - how?"

> The second part of my question is can I do the same with MS access
> ...

set o = createobject("access.application")
o.visible = true
o.usercontrol = true

set o = createobject("excel.application")
o.visible = true
o.usercontrol = true

set o = createobject("powerpoint.application")
o.visible = true

set o = nothing

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US



Sun, 17 Jul 2005 08:36:09 GMT  
 newbie question - trying to start applications with .vbs file
Thank you...
exactly what I wanted for excel & access...

however, I can't seem to do the same with MSProject.  This seems to be because
application.usercontrol is read-only in MSProject, and by just creating the
application object and then setting it's .visible = true, the MSProject window
just flashes by...  and if I do that a couple of times, and then change the
script to include application.projects.add, then there is a project1, project2,
etc,{*filter*} around, so I guess the only way to start up project is by creating
the msproject.application object and using that to add a new project, and
dealing with a Project1 (or 2 or 3 etc) that just hangs around (until I close it
or MSProject) right?

Thanks again.



Quote:
> > ...  I guess the first part of my
> > question is, "is there a way to start excel and project without
> > adding a dummy workbook/project? - how?"

> > The second part of my question is can I do the same with MS access
> > ...

> set o = createobject("access.application")
> o.visible = true
> o.usercontrol = true

> set o = createobject("excel.application")
> o.visible = true
> o.usercontrol = true

> set o = createobject("powerpoint.application")
> o.visible = true

> set o = nothing

> --
> Michael Harris
> Microsoft.MVP.Scripting
> Seattle WA US



Sun, 17 Jul 2005 21:58:31 GMT  
 newbie question - trying to start applications with .vbs file

Quote:
> however, I can't seem to do the same with MSProject.  ...

Sorry, I don't have MSProject so I can't experiment with that one...

Maybe it has a command line switch like Word does to open with creating a
blank document?

wshshell.run "winword.exe /n" ' runs word with no blank document

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US



Mon, 18 Jul 2005 09:26:40 GMT  
 newbie question - trying to start applications with .vbs file
Sorry, no solution (yet)  -- just a variation of your code...

    Option Explicit
    Dim arrAPP(5)
        arrAPP(0) = ""
        arrAPP(1) = "Excel"
        arrAPP(2) = "Word"
        arrAPP(3) = "MSProject"
        arrAPP(4) = "PowerPoint"
        arrAPP(5) = "Access"
    Dim strAPP
        strAPP = "Start MSOffice Application:" & vbCrLf & vbCrLf
    Dim intAPP
    For intAPP = 1 To UBound(arrAPP)
        arrAPP(0) = arrAPP(0) & intAPP
        strAPP = strAPP & vbTab & intAPP & " - " & arrAPP(intAPP) & vbCrLf
    Next
   '*
    Do
            intAPP = InputBox(strAPP,"MSO_Apps.vbs", 0)
        If (intAPP = "") Then Exit Do
        If Len(intAPP) = 1 And InStr(arrAPP(0),intAPP) > 0 Then
            intAPP = CInt(intAPP)
            Dim strOBJ
                strOBJ = arrAPP(intAPP) & ".Application"
            Dim objAPP
            Set objAPP = CreateObject(strOBJ)
                objApp.Visible = True
            If (intAPP = 1) _
            Or (intAPP = 5) Then
                objAPP.UserControl = True
            End If
            If (intAPP = 3) Then objAPP.Projects.Add
        Else
            MsgBox "Invalid selection!  Retry or 'Cancel'."
        End If
    Loop



Mon, 18 Jul 2005 12:16:07 GMT  
 newbie question - trying to start applications with .vbs file
Oh, sorry, I just presumed that everyone did...  silly of me.

Anyways, thanks for the idea to try a command line switch.  I'll try
experimenting with that.

Thanks for your help.


Quote:
> > however, I can't seem to do the same with MSProject.  ...

> Sorry, I don't have MSProject so I can't experiment with that one...

> Maybe it has a command line switch like Word does to open with creating a
> blank document?

> wshshell.run "winword.exe /n" ' runs word with no blank document

> --
> Michael Harris
> Microsoft.MVP.Scripting
> Seattle WA US



Tue, 19 Jul 2005 02:09:15 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. how to start an application with VBS

2. Newbie question - calling a VBS script from another VBS script

3. NEWBIE Question: How to get started...?

4. Newbie Question: How to start Microsoft Development Environment

5. Starting another application and waiting (newbie)

6. Newbie question - trying to call fortran dll from VB

7. Trying to understand SYSTEMTIME (Newbie API Question)

8. Calling *.vbs files to Run From Master VBS File

9. how to call vbs file from vbs file

10. Newbie question, getting started

11. What to Start From ? (newbie question)

12. Move Next, Prior, Last, Start, Newbie Question?

 

 
Powered by phpBB® Forum Software