Computer Forum Forum Index
Register  FAQ Profile Log in to check your private messages Log in Register 

add textbox while textbox is selected
Goto page Previous  1, 2, 3 ... , 14, 15, 16  Next
 
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word vba general
View previous topic :: View next topic  
Author Message
Greg Maxey
Guest





PostPosted: Sun Nov 11, 2007 8:34 pm    Post subject: Re: Checkbox -- delete or keep text Reply with quote

Try:
Sub Test()
Dim oPar As Paragraph
On Error Resume Next
ActiveDocument.Unprotect
On Error GoTo 0
For Each oPar In ActiveDocument.Paragraphs
If oPar.Range.FormFields(1).CheckBox.Value = False Then
oPar.Style = "Hidden"
Else
oPar.Style = "Normal"
oPar.Range.FormFields(1).Delete
End If
Next
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True
End Sub


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


MIrving wrote:
Quote:
Hi Greg

I found your macro perfect for deleting unselected check box
paragraphs.
The only additional functionality I would like to add to my document
is for the remaining check boxes (ie. the checked boxes) to also be
deleted, leaving only the paragraph text for the selected items. Is
there anyway of achieving this? Thank you for any suggestions.

"Greg" wrote:

Try something like this:

Sub Test()
Dim oPar As Paragraph
On Error Resume Next
ActiveDocument.Unprotect
On Error GoTo 0
For Each oPar In ActiveDocument.Paragraphs
If oPar.Range.FormFields(1).CheckBox.Value = False Then
oPar.Style = "Hidden"
Else
oPar.Style = "Normal"
End If
Next
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True
End Sub

This looks at the value of the "first" checkbox in each paragraph.

Add the macro to a toolbar button or keyboard shortcut.
Back to top
Google
Sponsor





PostPosted: Sun Nov 11, 2007 8:34 pm    Post subject: Advertisement

Back to top
Johan Verrept
Guest





PostPosted: Thu Nov 15, 2007 3:28 pm    Post subject: RE: Passing Word documents with macros as Sharepoint content Reply with quote

If you create the document through a content type with a template, there is
no Open event since you are not opening the template, but instantiating it in
a new document. Use the New Event.

"Ianb" wrote:

Quote:
Hi

I have been trying to nut this problem out for awhile now but not making
alot of progress. I am trying to integrate Word 2003 with Sharepoint 2007 as
follows:

I have a site with a template library. I have developed a content type in
another site and use it in a library.

I want the user to be able to select a content type in a library and have an
auto open event fire to open the sharepoint properties dialog. The user
populates the field presented and these cascade though fields in the
document. The fields are also available (as metadata) at the library list for
filtering grouping and sorting

Everything works fine except one thing. The problem is that when the content
type is chosen from the library the macro doesn't fire and on inspection the
macro is no longer available in the document. It does however fire and works
fine in the template library.

Does anyone know what is happening and how I can resolve this

Thanks

IanB
Back to top
jgrappy@gmail.com
Guest





PostPosted: Fri Nov 16, 2007 2:17 pm    Post subject: Re: Passing Word documents with macros as Sharepoint content Reply with quote

Johan, can you elaborate on this....I'm having the same problem. If I
use a word doc as a template to a content type, when I hit the new
button in my document library to create a new document based on that
orginal template doc, the macros are not in it. Why are they being
"stripped"? If I upload the same document to a document library and
open it, the macros are there and work as they should....any help
would be appreciated. Thanks!
Back to top
Rebecca Dell
Guest





PostPosted: Fri Nov 23, 2007 2:11 pm    Post subject: Re: Can I use a combo box without locking the document? Reply with quote

Hi there
I want to create a form with combo boxes but to only protect (using the
Protect Form button on the forms toolbar) the part of the document with the
combo boxes. I've tried adding the continuous breaks below.

I'm using the form with MS Navision and if the document/form is protected,
it won't merge data into the other parts of the form for me.

Thanks
Rebecca

"Word Heretic" wrote:

Quote:
G'day "bkotulka" <bkotulka@discussions.microsoft.com>,

Wrap the combo in continuous section breaks and only protect that
section.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


bkotulka reckoned:

This is because, I want to set up a template and use a combo box, but if I
lock the document, I won't be able to write in it.

Thanks

Back to top
martha
Guest





PostPosted: Thu Nov 29, 2007 5:36 pm    Post subject: Re: Macro on exit to fill Form Fields Reply with quote

This is EXACTLY what I need but it's not working for me. First of all it
does not enter the {} with Ctrl + F9 and it says this is an invalid bookmark,
regardless of how I get it in there? Can you tell me what I am doing wrong?
Thanks!!!

"Chad DeMeyer" wrote:

Quote:
In the form field options for the field on the first page, give the field a
meaningful name, something like "fName". On subsequent pages, use a REF
field:

{ REF fName }
Note: braces {} must be inserted with Ctrl + F9

In the form field options for the first field, put a checkmark next to
'Calculate on exit'.

Regards,
Chad


"amidget" <amidget@discussions.microsoft.com> wrote in message
news:97E544DE-AEEE-489D-9EBD-3FBF6916DC44@microsoft.com...
Form has duplicate fields on subsequent pages. When the first field is
filled in on the first page, I want all duplicate fields in the document to
auto populate.. i.e. Name field on first page of document. Name field on
second page of document. If the user types in their name in the first field,
on exit it will autopopulate in the rest of the document in the name field.
TIA Anna


Back to top
Doug Robbins - Word MVP
Guest





PostPosted: Thu Nov 29, 2007 7:24 pm    Post subject: Re: Macro on exit to fill Form Fields Reply with quote

Does your keyboard have an FLock key that must be pressed for the Function
Keys to act as they were originally intended to act before their purpose was
hijacked for other uses.

Did you change the name of the bookmark assigned to the formfield to which
you want to create the reference? You do that in the properties dialog for
the formfield.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"martha" <martha@discussions.microsoft.com> wrote in message
news:8FBF52E5-F1BD-4EDA-A06E-BDD478E17045@microsoft.com...
Quote:
This is EXACTLY what I need but it's not working for me. First of all it
does not enter the {} with Ctrl + F9 and it says this is an invalid
bookmark,
regardless of how I get it in there? Can you tell me what I am doing
wrong?
Thanks!!!

"Chad DeMeyer" wrote:

In the form field options for the field on the first page, give the field
a
meaningful name, something like "fName". On subsequent pages, use a REF
field:

{ REF fName }
Note: braces {} must be inserted with Ctrl + F9

In the form field options for the first field, put a checkmark next to
'Calculate on exit'.

Regards,
Chad


"amidget" <amidget@discussions.microsoft.com> wrote in message
news:97E544DE-AEEE-489D-9EBD-3FBF6916DC44@microsoft.com...
Form has duplicate fields on subsequent pages. When the first field is
filled in on the first page, I want all duplicate fields in the document
to
auto populate.. i.e. Name field on first page of document. Name field on
second page of document. If the user types in their name in the first
field,
on exit it will autopopulate in the rest of the document in the name
field.
TIA Anna


Back to top
jjbaker
Guest





PostPosted: Mon Dec 10, 2007 7:28 pm    Post subject: Re: Sending an Open Word 2007 document as an email attachmen Reply with quote

I have the same problem! PLEASE explain how to add the command you
suggested. Many, many thanks!!

"Graham Mayor" wrote:

Quote:
Add the command . 'Send to mail recipient' to the QAT.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Bucs85027 wrote:
I have seen and tried the Word 2003 sub that accomplishes this task,
but the script does not work in 2007. I am trying to send an open
document to a recipent or recipients as an email which is executed by
an Active X Command Box.
Any insights would be appreciated.


Back to top
Graham Mayor
Guest





PostPosted: Tue Dec 11, 2007 6:31 am    Post subject: Re: Sending an Open Word 2007 document as an email attachmen Reply with quote

Click the arrow at the right end of the QAT and select 'More Commands'
In the top left dialog box select All Commands then scroll down the list on
the left to 'Send To Mail Recipient' and add it to the list on the right.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

jjbaker wrote:
Quote:
I have the same problem! PLEASE explain how to add the command you
suggested. Many, many thanks!!

"Graham Mayor" wrote:

Add the command . 'Send to mail recipient' to the QAT.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Bucs85027 wrote:
I have seen and tried the Word 2003 sub that accomplishes this task,
but the script does not work in 2007. I am trying to send an open
document to a recipent or recipients as an email which is executed
by an Active X Command Box.
Any insights would be appreciated.
Back to top
Wayfarer007
Guest





PostPosted: Fri Dec 14, 2007 10:21 pm    Post subject: Re: Adding a Macro to CommandButton1 in a form Reply with quote

Hello Perry,
This works just fine... I'd like to be able to add my distribution list as
already filled in when the mail window opens. Can I do that also?

Thanks,
Judd


"Perry" wrote:
Try:

Private Sub CommandButton1_Click()
ActiveDocument.SendMail
End Sub

Krgrds,
Perry
Back to top
1
Guest





PostPosted: Tue Dec 18, 2007 11:09 am    Post subject: Re: Tricky IF Statement (tricky for me!) Reply with quote

Sorry for cross posting, but I might have initially put this in the
wrong group as I use word 2002 not 97.

If you can help, please reply to post in
microsoft.public.word.vba.general
Back to top
1
Guest





PostPosted: Tue Dec 18, 2007 11:12 am    Post subject: Re: Tricky IF Statement (tricky for me!) Reply with quote

On Dec 18, 10:09 pm, 1 <humphreybumph...@gmail.com> wrote:
Quote:
Sorry for cross posting, but I might have initially put this in the
wrong group as I use word 2002 not 97.

If you can help, please reply to post in
microsoft.public.word.vba.general

Frig I'm Dumb!!!

Original post in microsoft.public.word.word97vba:

I currently have a document with a custom form that asks the user for
information then a print button at the bottom of the form which prints
the information.

The print button has VB which sets up the variables for the text boxes
on the form then more vb which places the results from the variables
onto an A4 sheet. The VB then prints the sheet and closes the document
without saving it (as it doesn't need saving after printing). It then
closes word. The two lines of code I use to achieve the two closures
are:

ActiveDocument.Close (wdDoNotSaveChanges)
Application.Quit

Here's the full code for the print button:

Private Sub PrintBtn_Click()

'sets variable for each txtBox on form, just to make it easer
vName = Form.txtName
vAmount = Form.TxtAmount
vAmount2 = Form.TxtAmount2
vFor = Form.TxtFor

'Goes to each field on form and sets results equal to variables
ActiveDocument.FormFields("bkName").Result = vName
ActiveDocument.FormFields("bkAmount").Result = vAmount
ActiveDocument.FormFields("bkAmount2").Result = vAmount2
ActiveDocument.FormFields("bkFor").Result = vFor

'Remove Form from screen
Form.Hide

'Prints the form
Selection.EndKey Unit:=wdStory
Application.PrintOut FileName:="", Range:=wdPrintCurrentPage,
Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False

'Closes document and Word
ActiveDocument.Close (wdDoNotSaveChanges)
Application.Quit

End Sub

It all works fine except that my dilemma is that if there are other
word documents open, it will go through the closure procedure
(obviously as I'm using Application.Quit) and it asks if you want to
save the other open documents before exiting (as word usually does
when you close word without saving first).

This is no big deal for me, but as this document is set up for
clients, I don't want to tell them to just press Yes to save the
document/s or Cancel to keep the document/s open and keep working on
them, as they are the type of client who will get confused and press
No instead and lose their work.

If I take out the application.quit code and if there are no other open
documents, then the client is left with an open session of word with
no document open. This would confuse my clients even more!!

So far I have made this document as smooth as possible for them - they
open it, fill in four fields, press print and it automatically prints
and closes (without saving). Simple! But if other documents are
already open...

Is there an IF Statement I can use (in place of the two 'close'
commands) that asks:

if
there are other open documents besides 'this one'
then
leave them open and close this one without saving it
else
close word without saving this document'
(ie ActiveDocument.Close (wdDoNotSaveChanges)
Application.Quit)
End If

I hope this makes sense.

Thanks
Back to top
Graham Mayor
Guest





PostPosted: Tue Dec 18, 2007 12:07 pm    Post subject: Re: Tricky IF Statement (tricky for me!) Reply with quote

Do you mean like

ActiveDocument.Close (wdDoNotSaveChanges)
If Documents.Count = 0 Then
Application.Quit
End If

?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

1 wrote:
Quote:
On Dec 18, 10:09 pm, 1 <humphreybumph...@gmail.com> wrote:
Sorry for cross posting, but I might have initially put this in the
wrong group as I use word 2002 not 97.

If you can help, please reply to post in
microsoft.public.word.vba.general

Frig I'm Dumb!!!

Original post in microsoft.public.word.word97vba:

I currently have a document with a custom form that asks the user for
information then a print button at the bottom of the form which prints
the information.

The print button has VB which sets up the variables for the text boxes
on the form then more vb which places the results from the variables
onto an A4 sheet. The VB then prints the sheet and closes the document
without saving it (as it doesn't need saving after printing). It then
closes word. The two lines of code I use to achieve the two closures
are:

ActiveDocument.Close (wdDoNotSaveChanges)
Application.Quit

Here's the full code for the print button:

Private Sub PrintBtn_Click()

'sets variable for each txtBox on form, just to make it easer
vName = Form.txtName
vAmount = Form.TxtAmount
vAmount2 = Form.TxtAmount2
vFor = Form.TxtFor

'Goes to each field on form and sets results equal to variables
ActiveDocument.FormFields("bkName").Result = vName
ActiveDocument.FormFields("bkAmount").Result = vAmount
ActiveDocument.FormFields("bkAmount2").Result = vAmount2
ActiveDocument.FormFields("bkFor").Result = vFor

'Remove Form from screen
Form.Hide

'Prints the form
Selection.EndKey Unit:=wdStory
Application.PrintOut FileName:="", Range:=wdPrintCurrentPage,
Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False

'Closes document and Word
ActiveDocument.Close (wdDoNotSaveChanges)
Application.Quit

End Sub

It all works fine except that my dilemma is that if there are other
word documents open, it will go through the closure procedure
(obviously as I'm using Application.Quit) and it asks if you want to
save the other open documents before exiting (as word usually does
when you close word without saving first).

This is no big deal for me, but as this document is set up for
clients, I don't want to tell them to just press Yes to save the
document/s or Cancel to keep the document/s open and keep working on
them, as they are the type of client who will get confused and press
No instead and lose their work.

If I take out the application.quit code and if there are no other open
documents, then the client is left with an open session of word with
no document open. This would confuse my clients even more!!

So far I have made this document as smooth as possible for them - they
open it, fill in four fields, press print and it automatically prints
and closes (without saving). Simple! But if other documents are
already open...

Is there an IF Statement I can use (in place of the two 'close'
commands) that asks:

if
there are other open documents besides 'this one'
then
leave them open and close this one without saving it
else
close word without saving this document'
(ie ActiveDocument.Close (wdDoNotSaveChanges)
Application.Quit)
End If

I hope this makes sense.

Thanks
Back to top
1
Guest





PostPosted: Tue Dec 18, 2007 11:11 pm    Post subject: Re: Tricky IF Statement (tricky for me!) Reply with quote

On Dec 18, 11:07 pm, "Graham Mayor" <gma...@REMOVETHISmvps.org> wrote:
Quote:
Do you mean like

ActiveDocument.Close (wdDoNotSaveChanges)
If Documents.Count = 0 Then
Application.Quit
End If

?

--

Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


Yes, exactly that.

Thank you! It works perfectly
Back to top
1
Guest





PostPosted: Wed Dec 19, 2007 12:56 am    Post subject: Re: Tricky IF Statement (tricky for me!) Reply with quote

I have a new dilemma now. As this is a form to print cheques, my
client would like to know if they can type in a number and have it
automatically show up as text in dollars and cents somewhere else on
the page. At the moment they are typing the number (bkAmount) then
typing the text in another field (bkAmount2).

Therefore I somehow need to get rid of the Amount2 bookmark and
replace it with some conversion on the Amount bookmark somewhere else
on the page. I could use Ref bkAmount \* DollarText but this doesn't
give me the word "Dollars".

I have found the following macros but how do I run a macro to convert
a ref field automatically? The first macro assumes you're selecting
the text first.
<a href="http://groups.google.com.au/group/
microsoft.public.word.conversions/browse_thread/thread/
51f2a90faa801a4b/811c432a00eac36c?lnk=st&q=convert+number+to+text+in
+word+group%3A*word*#" Conversion of currency to english words in MS
word</a>

Or do I keep the Amount2 bookmark but instead of asking for the value
via the form (vAmount2) do I run some code that references the vAmount
figure, converts it and places it in bkAmount2?
Back to top
Graham Mayor
Guest





PostPosted: Wed Dec 19, 2007 7:33 am    Post subject: Re: Tricky IF Statement (tricky for me!) Reply with quote

See the item Formatting cash amounts in words on my web page
http://www.gmayor.com/formatting_word_fields.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

1 wrote:
Quote:
I have a new dilemma now. As this is a form to print cheques, my
client would like to know if they can type in a number and have it
automatically show up as text in dollars and cents somewhere else on
the page. At the moment they are typing the number (bkAmount) then
typing the text in another field (bkAmount2).

Therefore I somehow need to get rid of the Amount2 bookmark and
replace it with some conversion on the Amount bookmark somewhere else
on the page. I could use Ref bkAmount \* DollarText but this doesn't
give me the word "Dollars".

I have found the following macros but how do I run a macro to convert
a ref field automatically? The first macro assumes you're selecting
the text first.
a href="http://groups.google.com.au/group/
microsoft.public.word.conversions/browse_thread/thread/
51f2a90faa801a4b/811c432a00eac36c?lnk=st&q=convert+number+to+text+in
+word+group%3A*word*#" Conversion of currency to english words in MS
word</a

Or do I keep the Amount2 bookmark but instead of asking for the value
via the form (vAmount2) do I run some code that references the vAmount
figure, converts it and places it in bkAmount2?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word vba general All times are GMT
Goto page Previous  1, 2, 3 ... , 14, 15, 16  Next
Page 15 of 16

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Computer Forum