Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

Variable Storing a Document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve C - 24 Aug 2005 17:21 GMT
I wish to use a variable to identify and insert an existing Word document
(7A.doc) into another.  7A.doc is stored in the location G:\Sample.  If my
variable is called Category and stores the value "7A.doc", I am experiencing
a "Run-time error 5174 File could not be found" when I use it as follows:

Selection.InsertFile FileName:="G:\Sample\Category", Range:="",
ConfirmConversions:=False, Link:=False, Attachment:=False

What am I doing wrong?  Thanks!

Steve C
Chuck Henrich - 24 Aug 2005 17:40 GMT
FileName:="G:\Sample\Category" means you want to insert a file named
"Category" in the G:\Sample directory.

Your variable "Category" would need to be a string (because the FileName
parameter is a string, so you'd need to declare it properly:

Dim Category as String
Category = "G:\Sample\7A.doc"

Then you'd use it as follows:

Selection.InsertFile _
 FileName:=Category, _
 Range:="", _
 ConfirmConversions:=False, _
 Link:=False, _
 Attachment:=False

(note: no quotes around Category).

Signature

Chuck Henrich
www.ProductivityApps.com

> I wish to use a variable to identify and insert an existing Word document
> (7A.doc) into another.  7A.doc is stored in the location G:\Sample.  If my
[quoted text clipped - 7 lines]
>
> Steve C
Steve C - 24 Aug 2005 18:38 GMT
Thanks for the help, Chuck!

> FileName:="G:\Sample\Category" means you want to insert a file named
> "Category" in the G:\Sample directory.
[quoted text clipped - 27 lines]
> >
> > Steve C

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.