Hi,
This script works great in 2003 in formatting text brought from Access, but fails in 97 - unfortunately I don't have direct access to Excel 97 - can anyone with it (or with a compendious knowledge of the differences!) explain what's going wrong?
Hi,
This script works great in 2003 in formatting text brought from Access, but fails in 97 - unfortunately I don't have direct access to Excel 97 - can anyone with it (or with a compendious knowledge of the differences!) explain what's going wrong?
Re: Formatting Text Fails In 97 But Works In 2003
It's passworded...
You're wasting my time.
Re: Formatting Text Fails In 97 But Works In 2003
I've certainly not applied a password - nor is it passworded when I open it?
I've checked the 'protect worksheet' option and it's off etc!?
try nothing as a password (ie just click ok?)
Re: Formatting Text Fails In 97 But Works In 2003
My apologies... :footinmo:
I confused your app with someone elses I was looking at.
Now I guess I'm obligated to try to figure it out... darn.
OK, gimme a sec.
Re: Formatting Text Fails In 97 But Works In 2003
What Fails In 97 But Works In 2003?
Please ensure your title complies with section #1 of the Rules YOU Are Bound By.
Re: Formatting Text Fails In 97 But Works In 2003
He doesn't know... he said he didn't have 97.
I'm suspecting it might have to do with the CreateObject vb script. What exactly was the purpose of the macro? Perhaps we can recode it without the vb script.
Re: Formatting Text Fails In 97 But Works In 2003
Perhaps change the title to "Formatting Text Fails In 97 But Works In 2003".
Re: Formatting Text Fails In 97 But Works In 2003
hi there - yeah I know the title could have been clearer - but the damn thing interferes with everything I write!
Basically in 2003 you click the button and it'll remove all the square characters, formatting etc you can see and essentially tidy it up.
In 97 it doesn't even appear to ask if you want macros enabled like it normally does when it detects VBA attached and you click the button and it gives an error of 'function/sub not defined' (apologies but I'm trying to translate a non-technical user's translation of what they see!)
Re: Formatting Text Fails In 97 But Works In 2003
I rewrote your code cleaner to perform a more manual filtering of the strings. I don't see why this wouldn't work in 97. I think the problem had to do with that CreateObject line, but I can't confirm it (I don't have 97 around either).
PS... what's wrong with these people anyway? They're using a 10yr old app and they expect it'll just work forever?
Option Explicit
Sub Test()
Dim cell As Range
For Each cell In Selection
cell.WrapText = True
cell.Value = CleanUp(cell)
Next cell
End Sub
Function CleanUp(ByVal MyCell As Range) As String
Dim i As Integer, OK As Boolean
Dim MyStr As String, MyChr As Integer
MyStr = MyCell.Value
For i = 1 To Len(MyStr)
MyChr = Asc(Mid(MyStr, i, 1))
Select Case MyChr
Case 10, 32 To 255
OK = True
Case Else
OK = False
End Select
If OK Then CleanUp = CleanUp & Chr(MyChr)
Next i
End Function
Display More
Re: Formatting Text Fails In 97 But Works In 2003
Quote from omnikron32hi there - yeah I know the title could have been clearer - but the damn thing interferes with everything I write!
Personally, I have two issues with it myself...
1. It should probably allow the word "Excel"
2. It should allow series of all caps
Re: Formatting Text Fails In 97 But Works In 2003
Aaron: heh! yeah I've got more than two issues with it!
hmm I tried you code and it doesn't appear to work - even in 2003?
Doesn't appear to detect the characters - does this work for you?
Yeah - well you think 97's old - you should see the people using 97!
Re: Formatting Text Fails In 97 But Works In 2003
Worked just fine on my XL2003
Maybe you're not installing it correctly? I did notice you were attaching all your code to the worksheet objects.
Re: Formatting Text Fails In 97 But Works In 2003
yeah I figured I may well be being stupid!
Would it be possible for you to upload your version so I can see exactly how you've formatted/dropped the code?
Re: Formatting Text Fails In 97 But Works In 2003
This one works for me in 2003...
Don't think it would be a problem for XL97 either.
Re: Formatting Text Fails In 97 But Works In 2003
superb stuff! I get what you mean now! Thanks very much.
Re: Formatting Text Fails In 97 But Works In 2003
argh!
apparently on 97 it gives:
Run-time error '1004' Unable to get the SpecialCells property of the Range class
And on debug it highlights this line:
Set ProcRange = ProcRange.SpecialCells(xlConstants)
Did specialcells exist in 97? Is there another way to get this working - it seems like it's so close to working!
Re: Formatting Text Fails In 97 But Works In 2003
The problem with the original code is that xl97 (VB5) does not have the Replace function.
You could use SUBSTITUTE instead, ie:
change
to
Anyway your current problem is due to a bug in xl97 and CommandButtons TakeFocusOnClick property.
See here:http://support.microsoft.com/d…n-us;177527&Product=xlw97
Set the TakeFocusOnClick Property to False of the Command Button
or put in as 1st line of code:
Re: Formatting Text Fails In 97 But Works In 2003
Excellent - thanks for the great explanation!
Don’t have an account yet? Register yourself now and be a part of our community!