PDA

View Full Version : Solved: Insert a file with a passed variable



timetunnel
01-14-2007, 11:15 AM
Hello all:

Can anyone tell me how I can set up a word doc that will prompt the user for the names of 2 other word docs that I want to insert into the one they're working on?

I know how to do the insert code, but I don't know the best way to handle the prompting (input form or whatever) or how to pass the file names they specify on through to the insert statement.

Thanks in advance.

lucas
01-14-2007, 12:14 PM
Ann Troy gave this up a long time ago and it's just what your looking for.....bear in mind that better Word coders will probably come up with an easier solution but this one works great even if it is a little hard to set up initially.

There is a readme txt file in the zip and 2 doc files. Run the quoter.doc to add the data each to a new sheet. The quoter alt....doc will add it in line beginning with the first sheet and not add new sheets for each entry....

Hope this helps. remember to read the readme txt thouroughly so you will understand how to set this up.

Bob Phillips
01-14-2007, 12:15 PM
Just use Inputbox to get a value



ans = Inputbox("Name of first file")


this will just thorw up a dialog similar to a MsgBox, but within an input field.

timetunnel
01-14-2007, 04:18 PM
Thanks lucas & xld! Now I actually have to run into work. On a Sunday. Imagine that...

timetunnel
01-16-2007, 10:49 AM
Thanks everyone! I've now got input boxes passing values into variables and am able to use those to open and even save the corresponding files!

I know this is simple, but way cool from the users perspective!

Regards!

lucas
01-19-2007, 08:38 AM
Chuck has sent me an email with questions about post #2.


Hi Lucas:
You posted a zip file (in response to a problem I was having) with Ann's Quoter system and it's of great interest to me. However, after downloading and unzipping, I can't view the code. It says the project is locked and that's as far as I get. Anyway to unlock it? Can't unprotect it in anyway.
Thanks, Timetunnel (Chuck)

Your problem is a mystery to me Chuck as I just downloaded the file and opened both of the .doc files and the code is not password protected in either file. I also did not find the document to be protected.........

Open the file-Quoter.doc and when the form opens click ok to close the form.....hit alt-F11 to open the vbe. In the project explorer on the left(if not visable go to view and click on it)look for Userform1. Click on it and the code or object should show on the right. right click on it to view code. Sorry your having problems but I'm not sure what the problem could be.

Bob Phillips
01-22-2007, 03:39 AM
I can open it and see the code fine.

timetunnel
01-22-2007, 09:05 AM
After following your instructions I still can't see the code. It tells me that "project Locked Project is unviewable"

I'm running an older version of WORD and I suspect this has something to do with it. I'll take the stuff to work and see if I can open it there.

Thanks everyone!