Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't save Word Document - Error 5152

Status
Not open for further replies.

Jonath

Technical User
Joined
Jul 13, 2007
Messages
27
Location
FR
Greetings,

I'm working with Access/word 2007; I have a button on a form which allows users to fill a .doc and save it to C:

I used the method described in FAQ702-2379

All works fine, in particular:


Code:
file.activedocument.saveas ("C:\documents and settings\eric\mes documents\objectif\acompte " & Cstr(Forms![enqueteur]![Nom]) & ".doc")

BUT if I want to use a longer path, like
"C:\documents and settings\eric\mes documents\objectif\acomptes\acompte " ...

i get 5152 error "invalid file name...."

I tried with various combinations of names...didn't make it.
Is it possible that saving is limited to 4 folders/subfolders ?!? Is there any way to get past that?

Thanks in advance for any advice.

Jonath.
 
If my memory is correct, I think that you need to use double quotation marks
 
Thanks for answering rapidly, TimTDP

I think you found the source of my problem; I read something about the " character:

if the path contains many spaces, I have to put the string between double quotes (in addition to the standard ones), but I still can't make it work :-/

I can compile this, but still get the same error:

Code:
file.activedocument.saveas ("""C:\documents and settings\eric\mes documents\objectif\acomptes\acompte """ & Cstr(Forms![enqueteur]![Nom]) & ".doc")

any further advice?

Jonath
 
I used the following syntax to include double quotes

Dim myString As String
myString = chr$(34) + "c:\my long path\my long filename.txt" + chr$(34)
 
Thanks again, but this doesn't work...i still get an error

It seems I tried every combination, with double quotes, or ' :-/

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top