Home All Groups Group Topic Archive Search About

opening files and applications, same as if one did it by hand

Author
11 May 2007 3:24 PM
bt28
I would like to be able to do the following in visual basic.
First of all let me say that before I start writing the visual basic
program, I will know the full path name and file name of a file.
I want the program to open that file in a window. What I mean is that
it would have the same result as if I double clicked on the file icon
in the folder causing the file to open in a window.
(Actually I will want one block of code in the program to open several
files. I mention this because it seems from my limited experimenting
with the "record macro", that the application (for instance MS Word)
must be opened as part of opening the first MS Word file, but then
after that, the code for opening another file in MS Word is a little
simpler. But I am not sure of this. I am just guessing).

What would be even better is if I could have the program do this not
only for a file. But if it could do it for any application -- with the
same effect as if I, by hand, double clicked on the application icon.
(These applications will be known before I write the program).

One more thing. It has to do with me interacting with the visual basic
program. Suppose that several windows have thus been opened (files and
applications). And Windows focus is currently on one of the windows. I
would like to be able to type some sequence of keys that would be sent
not to the window currently in focus, but to the visual basic program
(where I can have the program analyze the key sequence and on that
basis do various things - for instance maybe open yet another file or
application. My experience is real good with string analysis and
manipulation in programming languages. But I need to know how to find
out how to break out of the focus on the current window and have the
string sent to the Visual Basic program, and also have the visual
basic program send the focus back to the window. )

I have worked with the record macro feature in MS Word and in MS Excel
- in fact in MS Excel I wrote some very big macros, although I used
the record macro feature to show me how to do certain things. Also,
recently I downloaded from Microsoft the Visual Basic Express and went
through most of the exercises.

In what way is the code generated by the MS Word record macro, related
to MS Visual Basic? How is it related to MS Visual Basic Express? Is
MS Visual Basic free or does it cost something? From what I read
somewhere it seemed MS will quit supporting MS Visual Basic in the not
too distant future. Is this true? Another question. When I bought my
latest computer and XP Windows about 2 years ago I was enrolled in a
course and on that basis I bought the Education Edition of MS Office.
I notice in certain places in the Visual Basic Express when I ask for
help, it gives a kind of obscure message that help for that is not
available on my system. Could this be due to my needing the full non-
Education version of Office?

Well, there are my questions. I guess they are a little long. But I
tried to make the description complete. Any information would be much
appreciated. My OS is XP Windows.

Author
11 May 2007 3:39 PM
Rick Rothstein (MVP - VB)
Show quote Hide quote
>I would like to be able to do the following in visual basic.
> First of all let me say that before I start writing the visual basic
> program, I will know the full path name and file name of a file.
> I want the program to open that file in a window. What I mean is that
> it would have the same result as if I double clicked on the file icon
> in the folder causing the file to open in a window.
> (Actually I will want one block of code in the program to open several
> files. I mention this because it seems from my limited experimenting
> with the "record macro", that the application (for instance MS Word)
> must be opened as part of opening the first MS Word file, but then
> after that, the code for opening another file in MS Word is a little
> simpler. But I am not sure of this. I am just guessing).
>
> What would be even better is if I could have the program do this not
> only for a file. But if it could do it for any application -- with the
> same effect as if I, by hand, double clicked on the application icon.
> (These applications will be known before I write the program).
>
> One more thing. It has to do with me interacting with the visual basic
> program. Suppose that several windows have thus been opened (files and
> applications). And Windows focus is currently on one of the windows. I
> would like to be able to type some sequence of keys that would be sent
> not to the window currently in focus, but to the visual basic program
> (where I can have the program analyze the key sequence and on that
> basis do various things - for instance maybe open yet another file or
> application. My experience is real good with string analysis and
> manipulation in programming languages. But I need to know how to find
> out how to break out of the focus on the current window and have the
> string sent to the Visual Basic program, and also have the visual
> basic program send the focus back to the window. )
>
> I have worked with the record macro feature in MS Word and in MS Excel
> - in fact in MS Excel I wrote some very big macros, although I used
> the record macro feature to show me how to do certain things. Also,
> recently I downloaded from Microsoft the Visual Basic Express and went
> through most of the exercises.
>
> In what way is the code generated by the MS Word record macro, related
> to MS Visual Basic? How is it related to MS Visual Basic Express? Is
> MS Visual Basic free or does it cost something? From what I read
> somewhere it seemed MS will quit supporting MS Visual Basic in the not
> too distant future. Is this true? Another question. When I bought my
> latest computer and XP Windows about 2 years ago I was enrolled in a
> course and on that basis I bought the Education Edition of MS Office.
> I notice in certain places in the Visual Basic Express when I ask for
> help, it gives a kind of obscure message that help for that is not
> available on my system. Could this be due to my needing the full non-
> Education version of Office?
>
> Well, there are my questions. I guess they are a little long. But I
> tried to make the description complete. Any information would be much
> appreciated. My OS is XP Windows.

I think the first order of business is to ask you which version of Visual
Basic are you asking this question for... one of the VBA languages embedded
in an Office product, Visual Basic Express (which I presume is from the
newer, dotnet product line), or VB5 or VB6 (either one from the "classic"
versions of Visual Basic)?

Rick
Author
13 May 2007 7:13 AM
bt28
On May 11, 8:39 am, "Rick Rothstein \(MVP - VB\)"
<rickNOSPAMn...@NOSPAMcomcast.net> wrote:
Show quoteHide quote
> >I would like to be able to do the following in visual basic.
> > First of all let me say that before I start writing the visual basic
> > program, I will know the full path name and file name of a file.
> > I want the program to open that file in a window. What I mean is that
> > it would have the same result as if I double clicked on the file icon
> > in the folder causing the file to open in a window.
> > (Actually I will want one block of code in the program to open several
> > files. I mention this because it seems from my limited experimenting
> > with the "record macro", that the application (for instance MS Word)
> > must be opened as part of opening the first MS Word file, but then
> > after that, the code for opening another file in MS Word is a little
> > simpler. But I am not sure of this. I am just guessing).
>
> > What would be even better is if I could have the program do this not
> > only for a file. But if it could do it for any application -- with the
> > same effect as if I, by hand, double clicked on the application icon.
> > (These applications will be known before I write the program).
>
> > One more thing. It has to do with me interacting with the visual basic
> > program. Suppose that several windows have thus been opened (files and
> > applications). And Windows focus is currently on one of the windows. I
> > would like to be able to type some sequence of keys that would be sent
> > not to the window currently in focus, but to the visual basic program
> > (where I can have the program analyze the key sequence and on that
> > basis do various things - for instance maybe open yet another file or
> > application. My experience is real good with string analysis and
> > manipulation in programming languages. But I need to know how to find
> > out how to break out of the focus on the current window and have the
> > string sent to the Visual Basic program, and also have the visual
> > basic program send the focus back to the window. )
>
> > I have worked with the record macro feature in MS Word and in MS Excel
> > - in fact in MS Excel I wrote some very big macros, although I used
> > the record macro feature to show me how to do certain things. Also,
> > recently I downloaded from Microsoft the Visual Basic Express and went
> > through most of the exercises.
>
> > In what way is the code generated by the MS Word record macro, related
> > to MS Visual Basic? How is it related to MS Visual Basic Express? Is
> > MS Visual Basic free or does it cost something? From what I read
> > somewhere it seemed MS will quit supporting MS Visual Basic in the not
> > too distant future. Is this true? Another question. When I bought my
> > latest computer and XP Windows about 2 years ago I was enrolled in a
> > course and on that basis I bought the Education Edition of MS Office.
> > I notice in certain places in the Visual Basic Express when I ask for
> > help, it gives a kind of obscure message that help for that is not
> > available on my system. Could this be due to my needing the full non-
> > Education version of Office?
>
> > Well, there are my questions. I guess they are a little long. But I
> > tried to make the description complete. Any information would be much
> > appreciated. My OS is XP Windows.
>
> I think the first order of business is to ask you which version of Visual
> Basic are you asking this question for... one of the VBA languages embedded
> in an Office product, Visual Basic Express (which I presume is from the
> newer, dotnet product line), or VB5 or VB6 (either one from the "classic"
> versions of Visual Basic)?
>
> Rick- Hide quoted text -
>
> - Show quoted text -

One Basic that I have is a Visual Basic Express that I downloaded from
MS on 4/16/2007. I did most of the exercises that could also be
downloaded.
When I do help on my VB Express I get the following

Microsoft Visual basic 2005

Microsoft visual studio 2005
Version 8.0.50727.42

Microsoft .NET framework
Version 2.0.50727


Then there is another VB that I have worked with in MS Word on my
system, using record macro and then adding more code. And I don't know
if the one in MS Excel is the same, but I have worked a lot with it
too. In either Word or Excel, when I edit macros, and look at help
info, I get
Microsoft Visual Basic 6.3

I am not sure if this answers your question. If I can get my questions
answered for anyone of these, that would be great.

Bob
Author
13 May 2007 1:03 PM
Ralph
<b***@greenxyz.com> wrote in message
Show quoteHide quote
news:1179040423.611479.113590@n59g2000hsh.googlegroups.com...
> <snipped>
>
> One Basic that I have is a Visual Basic Express that I downloaded from
> MS on 4/16/2007. I did most of the exercises that could also be
> downloaded.
> When I do help on my VB Express I get the following
>
> Microsoft Visual basic 2005
>
> Microsoft visual studio 2005
> Version 8.0.50727.42
>
> Microsoft .NET framework
> Version 2.0.50727
>

This version is not 'classic' Visual Basic which is the language/platform
supported by this newsgroup. You need to post your question in a newsgroup
with "dotnet" in the title...

>
> Then there is another VB that I have worked with in MS Word on my
> system, using record macro and then adding more code. And I don't know
> if the one in MS Excel is the same, but I have worked a lot with it
> too. In either Word or Excel, when I edit macros, and look at help
> info, I get
> Microsoft Visual Basic 6.3
>

This is actually "Microsoft Visual Basic for Applications 6.3" or VBA. It is
similar to, but not quite the same as VB. Different dialects exist for each
of the Office products. For specific answers you need to post in the
development group for the Office App you are using.

> <snippd>

-ralph