VBA, Modules, Userform and problems

D

Desastor

I developed a template used for client invoices. Upon opening th
template, I am prompted to input various demographics via popup windows
which are then used to be distributed to select areas within th
document via bookmarks. After entering those demographics I can the
proceed to add other relevant information. After I am finished with al
this I save the file into a document format and throw it onto a drive.


All this works fine.

The current problem occurs when I re-open the document for review o
edit at a later point in time. The popup windows I used to complete th
data entry initially show up again and again demand data to be entered.
I am wondering if there is an easy way to basically stop that routin
from running as it has no use at that time anymore.

Thanks in advance for any help offered.



Here is an example of one of the routines:

Sub RequestInfo()

'declare your variable

Dim strID As String

'set variable equal to whatever user types into input box

strID = InputBox("Enter Client's ID#:")

'declare a range

Dim bkID As Range

'set the range equal to your current bookmark

Set bkID = ActiveDocument.Bookmarks("bkID").Range

'pass in the info now contained in the variable (what the use
typed)

bkID.Text = strID

'wrap the same bookmark around this text

ActiveDocument.Bookmarks.Add "bkID", bkID

'select all text

Selection.WholeStory

'update fields

Selection.Fields.Update

'move cursor to deselect

Selection.MoveUp Unit:=wdLine, Count:=1

End Su
 

macropod

Microsoft MVP
Joined
Mar 2, 2012
Messages
578
Reaction score
50
Hi Desastor,

You could test one of your bookmarks for content before you get to the first InputBox:
If Trim(ActiveDocument.Bookmarks("bkID").Range.Text) <> "" Then Exit Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top