From: johnnykunst on
I have created a macro to generate filename from entries in a form in Word 2003 and save with this filename. The macro uses bookmarks to identify the text to be used. It works fine if the bookmark is for a legacy text form field, but if used with a drop down form field it generates a save error:

Private Sub CommandButton1_Click()
Call RunSpellcheck
Dim pStr As String
pStr = "C:\Users\John\Desktop\" 'Your directory
pStr = pStr + ActiveDocument.Bookmarks("text").Range.Text
pStr = pStr + " "
pStr = pStr + ActiveDocument.Bookmarks("ward").Range.Text
pStr = pStr + " .doc"
ActiveDocument.SaveAs FileName:=pStr
Dim sCode As String
MsgBox "Your Intelligence report was saved to the central WINTEL inbox for processing & emailing. No further action is required; it is now safe to close the document"
End Sub

Any help would be greatly appreciated- is there any way to use the selected text item from the drop down, or, if not, to copy & paste the text into a text form field which the macro will recognise?

---
frmsrcurl: http://msgroups.net/microsoft.public.word.vba.general/
From: Greg Maxey on

pStr = pStr + ActiveDocument.FormFields("text").Result



"johnnykunst" <user(a)msgroups.net/> wrote in message
news:uSxS7bY2KHA.5400(a)TK2MSFTNGP02.phx.gbl...
>I have created a macro to generate filename from entries in a form in Word
>2003 and save with this filename. The macro uses bookmarks to identify the
>text to be used. It works fine if the bookmark is for a legacy text form
>field, but if used with a drop down form field it generates a save error:
>
> Private Sub CommandButton1_Click()
> Call RunSpellcheck
> Dim pStr As String
> pStr = "C:\Users\John\Desktop\" 'Your directory
> pStr = pStr + ActiveDocument.Bookmarks("text").Range.Text
> pStr = pStr + " "
> pStr = pStr + ActiveDocument.Bookmarks("ward").Range.Text
> pStr = pStr + " .doc"
> ActiveDocument.SaveAs FileName:=pStr
> Dim sCode As String
> MsgBox "Your Intelligence report was saved to the central WINTEL inbox for
> processing & emailing. No further action is required; it is now safe to
> close the document"
> End Sub
>
> Any help would be greatly appreciated- is there any way to use the
> selected text item from the drop down, or, if not, to copy & paste the
> text into a text form field which the macro will recognise?
>
> ---
> frmsrcurl: http://msgroups.net/microsoft.public.word.vba.general/


From: johnnykunst on
pStr = pStr + ActiveDocument.FormFields("text").Result

Have tried the above and get the same problem:

Run-time error 5487: Word cannot complete the save due to a file permission error.

This is the same error as with the existing code I was using
Again, if I change the drip down to text it works fine, so it's still not picking up what's in teh drop down.

Please note, the Bookmark named text is a text field, the bookmark named ward is the drop down

---
frmsrcurl: http://msgroups.net/microsoft.public.word.vba.general/How-do-I-extract-text-from-drop-down-entry-in-Word-2003
From: johnnykunst on
The error message lists the file location, the name of the file as per the macto, but where the text from the drop down should be there is an unusual symbol something like this: ˦

---
frmsrcurl: http://msgroups.net/microsoft.public.word.vba.general/How-do-I-extract-text-from-drop-down-entry-in-Word-2003
From: johnnykunst on
Additionally, could it be that a specific reference in VBA needs to be set up so that the macro picks up the drop down ebtry?

---
frmsrcurl: http://msgroups.net/microsoft.public.word.vba.general/How-do-I-extract-text-from-drop-down-entry-in-Word-2003
 |  Next  |  Last
Pages: 1 2
Prev: CREDIT CARD
Next: Sorting in VBA