VB6 app used to open Word docs - capture doc names?

E

Ed from AZ

I use a VB6 application to open Word documents (Word 2000). The app
has a drop-down list - I select the doc and it opens. When the doc is
open, Word is at the front as the active application; when I close the
doc or quit the Word app, the VB app again becomes the active
application.

Sometimes I will notice an error in the Word doc. While I'm using
this app, I can't stop to write down the name of the doc to go back to
it and make corrections. I've got an array in the VB app that stores
the names of each doc it opens, but that presents me with a list of
many docs with no errors and one or two buried in the list that need
correcting.

I'm thinking that with the Word app active, I could use a Word macro
to capture the doc name and send it back to the VB app somehow. But
how? I only have time to hit a simple keystroke combo to run a macro,
and then I need to open another doc. I can't communicate directly to
the VB app because it's not active. I can't hold an array in the Word
app because it might be quit rather than just closing the doc.

I'm sure there are other options I haven't thoguht of. If someone
could drop-kick me in the right direction, I would be much obliged.

Ed
 
N

Norm

Ed said:
I use a VB6 application to open Word documents (Word 2000). The app
has a drop-down list - I select the doc and it opens. When the doc is
open, Word is at the front as the active application; when I close the
doc or quit the Word app, the VB app again becomes the active
application.

Sometimes I will notice an error in the Word doc. While I'm using
this app, I can't stop to write down the name of the doc to go back to
it and make corrections. I've got an array in the VB app that stores
the names of each doc it opens, but that presents me with a list of
many docs with no errors and one or two buried in the list that need
correcting.

I'm thinking that with the Word app active, I could use a Word macro
to capture the doc name and send it back to the VB app somehow. But
how? I only have time to hit a simple keystroke combo to run a macro,
and then I need to open another doc. I can't communicate directly to
the VB app because it's not active. I can't hold an array in the Word
app because it might be quit rather than just closing the doc.

I'm sure there are other options I haven't thoguht of. If someone
could drop-kick me in the right direction, I would be much obliged.

Ed

Ed,

What type of error in the Word app are you talking about? I do something
similar in an app, but when I open a Word document I also have a vb toolbar
form that opens always on top of the word document and has three ways of
closing the Word documents, one closes all open documents, one closes only
the top document, the third one closes and saves all changes. You could also
have a function for closing and saving the name of the document just closed
if you wanted.

Norm

--
Norm

Don't blame me, my programming is
self-taught and my teacher was not
very experienced. :)

normfowler_don't (e-mail address removed)
 
M

Matt Williamson

Ed said:
I use a VB6 application to open Word documents (Word 2000). The app
has a drop-down list - I select the doc and it opens. When the doc is
open, Word is at the front as the active application; when I close the
doc or quit the Word app, the VB app again becomes the active
application.

Sometimes I will notice an error in the Word doc. While I'm using
this app, I can't stop to write down the name of the doc to go back to
it and make corrections. I've got an array in the VB app that stores
the names of each doc it opens, but that presents me with a list of
many docs with no errors and one or two buried in the list that need
correcting.

I'm thinking that with the Word app active, I could use a Word macro
to capture the doc name and send it back to the VB app somehow. But
how? I only have time to hit a simple keystroke combo to run a macro,
and then I need to open another doc. I can't communicate directly to
the VB app because it's not active. I can't hold an array in the Word
app because it might be quit rather than just closing the doc.

I'm sure there are other options I haven't thoguht of. If someone
could drop-kick me in the right direction, I would be much obliged.

Ed

Just add another Global macro to write the name of the current doc to a
text file and hotkey it. When you see an error, hit your hotkey and then
you have a log of all the error files to review later.

HTH

Matt
 
E

Ed from AZ

Hi Matt.
Just add another Global macro to write the name of the current doc to a
text file and hotkey it. When you see an error, hit your hotkey and then
you have a log of all the error files to review later.

Oh - that's simple! Which is probably why I didn't think of it!

Sub ErrLog

Set objLog to text file
If error, create new text file

Write docName to ErrLog
Save, Close ErrLog

Set objLog = Nothing

End Sub

Something like that? Using FSO and TextStream?

Ed
 
M

Matt Williamson

Ed said:
Hi Matt.


Oh - that's simple! Which is probably why I didn't think of it!

Sub ErrLog

Set objLog to text file
If error, create new text file

Write docName to ErrLog
Save, Close ErrLog

Set objLog = Nothing

End Sub

Something like that? Using FSO and TextStream?

Ed

I only use FSO from script but you can use it in VBA if you want.

I'd do it something like this:

<air code>

Sub LogError()

dim sErrorLog as string, ff as long
dim sDocPath as string

ff = freefile
sErrorLog = "C:\path\Errlog.txt"
sDocPath = activedocument.path & "\"

Open sErrorLog for append as #ff
write #ff, sDocPath
close #ff

End Sub

HTH

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top