473,387 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Write a VBA created word doc to a specific location

Hello,

I have the following code segment that creates a word document from Access VBA.

Dim oWord As New.Application
Dim strTN As String

With oWord

.Documents.Add "\\ServerName\Fred\Templates\Fred.dot"
.Selection.GoTo wdGoToBookmark, , , "bmkName"
.Selection.TypeText Me.txtName
.
.
.Visible = False

End With

I want to write the created document Fred.doc to a particular location. If I hard code the required pathname in it works using this
.ActiveDocument.SaveAs FileName:= "\\ServerName\Fred\Number\Fred.doc"

But the 'Number' Folder is a variable name and I want to use something like
PathName = "\\ServerName\Fred\" & strNumber & "\Fred.dot"
then
.ActiveDocument.SaveAs FileName:= PathName

But this does not work I get an error dialouge boe that says
"Error in Sub TransferToWord
Description: This is not a valid file name. Error Number: 5152"

ANY IDEAS. Also, should I close the file before saving.

Many Thanks
Laurence
Aug 26 '09 #1
1 2185
kadghar
1,295 Expert 1GB
perhaps its Fred.doc instead of .dot
^.^

and... im not sure, but maybe you have to create the folders first...

and no, you can save when the file is open, that shouldn't give you an error
Sep 3 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Xenia | last post by:
Hello! Is anyone can help me to figure out how to write some xml into huge xml file into speceific location??? Say, i have a file about 139 Mb and i need to write some data (xml) into it, but...
2
by: Ptaku25 | last post by:
Hello All, I would like to insert some text in specific location in MS Word document under app written in BCB6, location of the document I mean that I want to insert some text eg. after...
3
by: john | last post by:
I need to produce a RTF-document which is filled with data from a database. I've created a RTF-document in WordPad (a template, so to speak) which contains 'placeholders', for example '<dd01>',...
9
by: Mike Fellows | last post by:
I'm trying to create a server side application (through a web front end) that allows me to print specific documents from the server im using: Dim wordapp = New Word.Application and have...
2
by: fordesky | last post by:
Gday, I have a set of Access 2000 tables that I would like to export into a MS Word 2000 template at specific bookmark locations that I've set up. Would anyone know the code to achieve...
0
by: R Reyes | last post by:
ISSUE (reposted) =========================== Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? For many people, they say they add the...
1
by: R Reyes | last post by:
ISSUE (reposted) =========================== Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? For many people, they say they add the...
6
by: mcnews | last post by:
How can I direct Response.Write to output to a specific location on my page? TIA, mcnewsxp
0
by: prashant | last post by:
Hi all I need to write into word document through VB.NET. The data is supposed to come from the textbox created by me using the com addins. The text box is appears in the command bar area. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.