Macro to insert file, pause, get response, act on response

J

jerem

I'm trying to write a macro which will insert a file (varying files from a
document management system - Imanage), pause and wait for the user to input
the document number and then act on the user's response. Can't seem to get
that code using the Macro Recorder in Word - don't know how to tell it to
pause and wait for a response from the user. Any help would be appreciated.
 
J

Jonathan West

jerem said:
I'm trying to write a macro which will insert a file (varying files from a
document management system - Imanage), pause and wait for the user to
input
the document number and then act on the user's response. Can't seem to
get
that code using the Macro Recorder in Word - don't know how to tell it to
pause and wait for a response from the user. Any help would be
appreciated.

Use the InputBox function. Look it up in the VBA Help
 
J

jerem

I did look it up, however, it's like I now have the verb with no nouns and
adjectives (or vice versa) to form a complete sentence. My VBA is extremely
limited. I generally try to get as much code generated through the Recorder
in Word, or I scavenge this site for pieces of code that I can decipher and
tweak to fit my needs - whether or not the code is efficient - if I get it to
work, it's good enough for me -- which leads to this question - can you
recommend a good book which covers VBA in the Word environment. There is a
book by Steven Roman called Word Macros - are you familiar with this book or
do you have any suggestions?

Thanks for your help and response.
 
N

NZ VBA Developer

G'day jerem!

Can't help you with your main question, but as for a reference guide to VBA,
Steven Roman's book is about the only one out there - other than a couple of
'Idiot's/Dummies' guides. Reviews on it have been mixed - search Amazon to
see what I mean - but I quite like it. It's the book I started with, and
between it, the macro recorder and the VBA help, I've become quite
proficient. (I also did an intro to Word macros course at the local polytech,
but I knew more than the instructor.) I haven't spent a lot of time on the
MVP sites, but what I have seen looks very good. And then there is always
this forum - thanks everyone!

Of course it helps to have a bit of exposure to programming in general,
altho in my case, that was a couple of intro classes at uni 20-mumble years
ago (BASIC & FORTRAN - eek!). Even so, I'm not a programmer; my forte is
technical writing, and my interest in VBA came about from necessity and the
desire to work more efficiently.

My advice: get the book, keep doing what you're doing and adopt the Kiwi
philosophy - Give it a go! She'll be right, mate!
 
G

Greg Maxey

Maybe something like this will do:


Sub ScratchMacro()
Dim pName As String
Dim oRng As Word.Range
Dim Source As Document
With Dialogs(wdDialogInsertFile)
.Display
pName = WordBasic.FilenameInfo$(.Name, 1)
End With
Set oRng = ActiveDocument.Range
oRng.Collapse wdCollapseEnd
oRng.InsertBefore (InputBox("Enter the file number: ") & vbCr)
oRng.Collapse wdCollapseEnd
oRng.InlineShapes.AddOLEObject FileName _
:=pName, LinkToFile:=False, DisplayAsIcon:=False
End Sub
 
J

jerem

G'day NZ VBA Developer,

Ditto to most of what you wrote - I took computer programming back in the
day - won't tell you what day - that will age me but you'll probably figure
out once I list languages - took a course in Assembly language and Cobol -
and when you had to keypunch your code in. So am aware of Ifs, Thens, Loops,
etc. but have not used much VBA so don't know how to speak that language
yet. Will take your advice then and get the book. Need to learn to speak
the language since I, too, have the need to work more efficiently. Thanks
again for the advice.
 
G

Graham Mayor

I knew you couldn't stay away for long ;)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

jerem

Hi Greg,

Tried your code - some very weird things happen though. First problem is it
only looks to non-network areas (i.e., c drive, desktop, etc) - will not let
me insert a file from Imanage (my company's document management system).
Second and here's where the weird stuff begins - even if you select a
document from the local drive, it brings that document in as a Picture (first
weird thing) and it does so as a document within a document (second weird
thing) and the name will read something like: Document in Document 4.

I then tried to do an Object, Convert to Word, but that does not work.
What goes on with this macro - very, very strange. But thanks for trying to
help.
 
G

Greg Maxey

I don't really know anything about your companies file management system. I
was just trying to show you how to insert a InputBox that requires the user
to enter some data before the file is acutally inserted. The wierd things
are probably do to the fact that the file is inserted as an object (not just
text).
 
N

NZ VBA Developer

jerem,

I've had a bit of experience with iManage/Interwoven, and altho I can't give
you an answer that explains everything that's happening, I do know that
you'll struggle to retrieve a document from iManage's store. iManage security
pretty much only lets iManage have access to it, so even if you have the
document ID you just won't be able to get there from here. (The document ID
is really just a pointer in a SQL database that tells iManage where to look;
the actual filename probably isn't even remotely the same.) The only way I
know of to work with stored documents is to use the native iManage
functionality to save a copy of the document locally and then perform any
operations using the local copy.

It appears from your original post that you want to drive the iManage
interface using VBA. I can just about guarantee that you won't have much joy
there as the iManage API isn't exposed enough to allow VBA to run it - and
the part that is exposed is pretty arcane. The best I've been able to do is
minor tweaks to the iManO2K template (the one that links Word and iManage) to
fine tune the auto-profile process a bit.

If it's critical that you be able to do what you're trying to do, talk to
your friendly Interwoven engineer about a bit of custom development - and
then be prepared for a bit of 'sticker shock' when you get the quote. ;-)
 
J

jerem

I figured as much. Am automating certain operations I have to do within a
document, however, previous to even doing that I have to either copy or
insert certain other documents. Thought it would be even more efficient to
address that step within the macro as well. So, it's not critical that I do
it - just thought it would save even more time if I could accomplish that as
well in one sweep. Thanks for the info.
 

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