Assign Unicode values to text strings in Project via VBA?

D

dgmoore

I need to display a character from the extended ANSI character set in a
text column in Project. I have determined by copy and paste that
Project is able to display the character (a black square, Unicode
9632).

My thought was to enter some standard character in the column in
question in the appropriate rows and then iterate through the rows and
change the Unicode to the desired value. However, attempting to
directly assign a Unicode value to a character using the AscW()
function (e.g., AscW(Left([String],1)) = 9632) results in an error.

Can anybody suggest a way in VBA to display Unicode character 9632 a
Project text field?

Thanks

Dave
 
J

John

I need to display a character from the extended ANSI character set in a
text column in Project. I have determined by copy and paste that
Project is able to display the character (a black square, Unicode
9632).

My thought was to enter some standard character in the column in
question in the appropriate rows and then iterate through the rows and
change the Unicode to the desired value. However, attempting to
directly assign a Unicode value to a character using the AscW()
function (e.g., AscW(Left([String],1)) = 9632) results in an error.

Can anybody suggest a way in VBA to display Unicode character 9632 a
Project text field?

Thanks

Dave

Dave,
It fails because the AscW function returns the character code, it
doesn't "write" it. Try something like the following:
ActiveProject.Tasks(1).Text1 = ChrW(9632)

Hope this helps.
John
Project MVP
 
D

dgmoore

Well, some days you're the windshield and some days you're the bug.
Your suggestion works perfectly, and I was looking at the problem with
blinders on.
Thanks!
Dave said:
I need to display a character from the extended ANSI character set in a
text column in Project. I have determined by copy and paste that
Project is able to display the character (a black square, Unicode
9632).

My thought was to enter some standard character in the column in
question in the appropriate rows and then iterate through the rows and
change the Unicode to the desired value. However, attempting to
directly assign a Unicode value to a character using the AscW()
function (e.g., AscW(Left([String],1)) = 9632) results in an error.

Can anybody suggest a way in VBA to display Unicode character 9632 a
Project text field?

Thanks

Dave

Dave,
It fails because the AscW function returns the character code, it
doesn't "write" it. Try something like the following:
ActiveProject.Tasks(1).Text1 = ChrW(9632)

Hope this helps.
John
Project MVP
 
J

JackD

I think you have AscW mixed up with ChrW

Sub changefirstchar()
ActiveProject.Tasks(1).Name = ChrW(9632)
End Sub

displays that black square as the name of the first task in the project.
If you want to do a find and replace based on some standard character you
have entered, then something like

if left(mystring,1) = "#" then
mystring = ChrW(9632) & right(mystring, len(mystring) - 1)
end if
 
J

John

Well, some days you're the windshield and some days you're the bug.
Your suggestion works perfectly, and I was looking at the problem with
blinders on.
Thanks!
Dave

Dave,
I know what you mean. Sometimes it seems I'm the bug more often than the
windshield.

John
 

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