creating bookmarks

Q

Qreg

Hello,

I'm new to writing macros under MS word, therefore my problem can be
trivial to You.

I've created a macro that inserts and formats a table and then inserts a
{SEQ Eq} counter then I want to create a bookmark for this counter. The
name for it I want to get from UserForm TextBox, I've written all this but
somehow I get an error that used Bookmark name is wrong.

Thanks in advance

Wojtek
 
D

Dave Lett

Hi Wojtek,

If your UserForm TextBox text has spaces in it, then this might be causing
the problem. For example, "My Textbox Text" cannot be the name of a
bookmark, but "MyTextboxText" can. If this is the case, then you can use the
Replace function to remove the spaces.

HTH,
Dave
 
Q

Qreg

Dave,

I've used only one world name, and the problem is that I somehow cannot
pass the name entered in UserForm (texbox) to the code below:

With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:=Variable_name
.DefaultSorting = wdSortByName
.ShowHidden = False
End With

The Variable_name is declared as:

Dim Variable_name As String

And is read from the userform using:

Variable_name = TextBox1.Text

Hope this additional info will allow You to find what I'm doing wrong.

Wojtek
 
Q

Qreg

Dnia Thu, 14 Apr 2005 15:34:12 +0100, Jonathan West napisa³(a):
Hi Qreg,

Does the text typed into TextBox1 ever contain any spaces? If so, you will
get an error because bookmark names cannot contain spaces.

Ok I got it working. It was my stupid mistake, I had a private variable in
the other function, so it didn't pass anything to the main one.

Wojtek
 

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