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 / November 2005

Tip: Looking for answers? Try searching our database.

you excuse my tongue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fedora - 06 Nov 2005 17:14 GMT
Good morning to everybody. I have windows xp service pack 2 with word 2003.
With a button, i would like to save with name the forms field document
(protégé) taking the name from a text form field name, field no. 3, max 25
characters (if number lower, all)  not to be to type in it every time. And
feasible that with macro? Is it possible also to choose where to save it? ex.
desktop folder. Friends thanks. if possible, step by step please.
Helmut Weber - 07 Nov 2005 14:09 GMT
Hi Fedora,

like this, to get you started.

Private Sub CommandButton1_Click()
Dim sPth As String
Dim sNam As String
sPth = "c:\test\"
sNam = ActiveDocument.FormFields(1).Result
If Len(sNam) > 25 Then
  MsgBox "too long"
Else
  ActiveDocument.SaveAs sPth & sNam & ".doc"
End If
End Sub

assuming, you have a commandbutton from
the control toolbox, or whatever it is called in French, I guess.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

fedora - 07 Nov 2005 16:31 GMT
Well Helmut, thanks. I would however like if the fieldname is >=25, take the
first 25 characters, non' too long' but save any way. if it is difficult I
entirely take the name of the field. in the same Private Sub
CommandButton1_Click () would like to insert an condition which always checks
if "c:\test\" there is already, otherwise create it. is it possible? Thanks
many.  Greetings from, Tuscan, Italy. Ciao Fedora

> Hi Fedora,
>
[quoted text clipped - 14 lines]
> assuming, you have a commandbutton from
> the control toolbox, or whatever it is called in French, I guess.
Helmut Weber - 08 Nov 2005 09:54 GMT
Hi Fedora,

if you want the left 25 characters, then

sName= left(sNam, 25)

This works even if there are less then 25 characters.

To check, whether a directory exists, etc.

If Dir("c:\testdir\", vbDirectory) = "" Then
  MkDir "c:\testdir\"
End If

Signature

HTH

Helmut Weber, MVP WordVBA

"red.sys" & chr$(64) & "t-online.de"
Win XP, Office 2003

fedora - 08 Nov 2005 14:29 GMT
hi helmut, really professional, punctual and effective. Everything works to
wonder. thanks, many thanks. you are good.
Fedora.
 
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.