#1   Report Post  
Posted to microsoft.public.word.docmanagement
sogani sogani is offline
external usenet poster
 
Posts: 1
Default O2 (Oxegen)

How to write chemical symbol like Silica (SiO2)
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default O2 (Oxegen)

Investigate Subscript and Superscript font attributes (CTRL+Shift++ and
CTRL+=)
If you have lots of chemical formulae to write you may find - 'Format part
of a found text string in a list of items' at
http://www.gmayor.com/word_vba_examples.htm useful

--

Graham Mayor - Word MVP

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



sogani wrote:
How to write chemical symbol like Silica (SiO2)



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default O2 (Oxegen)

If you have lots of chemical formulae to write you may find - 'Format part of a found text string in a list of items'

Or the following macro, written specifically for chemical formulae:
Sub ChemicalFormatter()
Dim oRng As Range, fRng As Range, bState As Boolean
Application.ScreenUpdating = False
Select Case MsgBox("Do you want to process the whole document?", _
vbYesNoCancel + vbQuestion, "Chemical Formatter")
Case vbYes
bState = True
Case vbNo
bState = False
Case vbCancel
End
End Select
With Selection
Set oRng = .Range
With .Find
.ClearFormatting
.Text = "[A-Za-z)][0-9]{1,}"
.MatchWildcards = True
.Wrap = wdFindContinue
.Forward = True
Do While .Execute = True
Set fRng = ActiveDocument.Range(Start:=Selection.Start + 1, End:=Selection.End)
If bState = False Then
If fRng.Start = oRng.End Then Exit Do
If fRng.End = oRng.End Then fRng.End = oRng.End
End If
fRng.Font.Subscript = True
fRng.Collapse Direction:=wdCollapseEnd
Loop
End With
End With
oRng.Select
Set fRng = Nothing
Set oRng = Nothing
Application.ScreenUpdating = True
End Sub
The above macro will search the active document for all numbers preceded by a letter or a right bracket, and subscript just the
numbers.

If your document has other alphanumeric strings in which a number follows a letter (eg Table cell references), you'll need to select
only the range(s) containing the text to be converted and answer 'No' to the prompt.


--
Cheers
macropod
[Microsoft MVP - Word]


"Graham Mayor" wrote in message ...
Investigate Subscript and Superscript font attributes (CTRL+Shift++ and CTRL+=)
If you have lots of chemical formulae to write you may find - 'Format part of a found text string in a list of items' at
http://www.gmayor.com/word_vba_examples.htm useful

--

Graham Mayor - Word MVP

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



sogani wrote:
How to write chemical symbol like Silica (SiO2)




  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default O2 (Oxegen)

A problem with chemical formulae is that they don't all use subscript.

--

Graham Mayor - Word MVP

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



macropod wrote:
If you have lots of chemical formulae to write you may find -
'Format part of a found text string in a list of items'


Or the following macro, written specifically for chemical formulae:
Sub ChemicalFormatter()
Dim oRng As Range, fRng As Range, bState As Boolean
Application.ScreenUpdating = False
Select Case MsgBox("Do you want to process the whole document?", _
vbYesNoCancel + vbQuestion, "Chemical Formatter")
Case vbYes
bState = True
Case vbNo
bState = False
Case vbCancel
End
End Select
With Selection
Set oRng = .Range
With .Find
.ClearFormatting
.Text = "[A-Za-z)][0-9]{1,}"
.MatchWildcards = True
.Wrap = wdFindContinue
.Forward = True
Do While .Execute = True
Set fRng = ActiveDocument.Range(Start:=Selection.Start + 1,
End:=Selection.End) If bState = False Then
If fRng.Start = oRng.End Then Exit Do
If fRng.End = oRng.End Then fRng.End = oRng.End
End If
fRng.Font.Subscript = True
fRng.Collapse Direction:=wdCollapseEnd
Loop
End With
End With
oRng.Select
Set fRng = Nothing
Set oRng = Nothing
Application.ScreenUpdating = True
End Sub
The above macro will search the active document for all numbers
preceded by a letter or a right bracket, and subscript just the
numbers.
If your document has other alphanumeric strings in which a number
follows a letter (eg Table cell references), you'll need to select
only the range(s) containing the text to be converted and answer 'No'
to the prompt.


"Graham Mayor" wrote in message
...
Investigate Subscript and Superscript font attributes (CTRL+Shift++
and CTRL+=) If you have lots of chemical formulae to write you may find -
'Format part of a found text string in a list of items' at
http://www.gmayor.com/word_vba_examples.htm useful --

Graham Mayor - Word MVP

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



sogani wrote:
How to write chemical symbol like Silica (SiO2)



  #5   Report Post  
Posted to microsoft.public.word.docmanagement
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default O2 (Oxegen)

Hi Graham,

There's always a fly in the ointment, so to speak. AFAIK, most (if not all) of the chemical formulae numbers that aren't subscripted
are at the start of the formula. My macro leaves those numbers alone.

--
Cheers
macropod
[Microsoft MVP - Word]


"Graham Mayor" wrote in message ...
A problem with chemical formulae is that they don't all use subscript.

--

Graham Mayor - Word MVP

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



macropod wrote:
If you have lots of chemical formulae to write you may find -
'Format part of a found text string in a list of items'


Or the following macro, written specifically for chemical formulae:
Sub ChemicalFormatter()
Dim oRng As Range, fRng As Range, bState As Boolean
Application.ScreenUpdating = False
Select Case MsgBox("Do you want to process the whole document?", _
vbYesNoCancel + vbQuestion, "Chemical Formatter")
Case vbYes
bState = True
Case vbNo
bState = False
Case vbCancel
End
End Select
With Selection
Set oRng = .Range
With .Find
.ClearFormatting
.Text = "[A-Za-z)][0-9]{1,}"
.MatchWildcards = True
.Wrap = wdFindContinue
.Forward = True
Do While .Execute = True
Set fRng = ActiveDocument.Range(Start:=Selection.Start + 1,
End:=Selection.End) If bState = False Then
If fRng.Start = oRng.End Then Exit Do
If fRng.End = oRng.End Then fRng.End = oRng.End
End If
fRng.Font.Subscript = True
fRng.Collapse Direction:=wdCollapseEnd
Loop
End With
End With
oRng.Select
Set fRng = Nothing
Set oRng = Nothing
Application.ScreenUpdating = True
End Sub
The above macro will search the active document for all numbers
preceded by a letter or a right bracket, and subscript just the
numbers.
If your document has other alphanumeric strings in which a number
follows a letter (eg Table cell references), you'll need to select
only the range(s) containing the text to be converted and answer 'No'
to the prompt.


"Graham Mayor" wrote in message
...
Investigate Subscript and Superscript font attributes (CTRL+Shift++
and CTRL+=) If you have lots of chemical formulae to write you may find -
'Format part of a found text string in a list of items' at
http://www.gmayor.com/word_vba_examples.htm useful --

Graham Mayor - Word MVP

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



sogani wrote:
How to write chemical symbol like Silica (SiO2)






  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default O2 (Oxegen)

'Fraid not all - see the examples at
http://en.wikipedia.org/wiki/Chemical_formula
--

Graham Mayor - Word MVP

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



macropod wrote:
Hi Graham,

There's always a fly in the ointment, so to speak. AFAIK, most (if
not all) of the chemical formulae numbers that aren't subscripted are
at the start of the formula. My macro leaves those numbers alone.

"Graham Mayor" wrote in message
...
A problem with chemical formulae is that they don't all use
subscript. --

Graham Mayor - Word MVP

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



macropod wrote:
If you have lots of chemical formulae to write you may find -
'Format part of a found text string in a list of items'

Or the following macro, written specifically for chemical formulae:
Sub ChemicalFormatter()
Dim oRng As Range, fRng As Range, bState As Boolean
Application.ScreenUpdating = False
Select Case MsgBox("Do you want to process the whole document?", _
vbYesNoCancel + vbQuestion, "Chemical Formatter")
Case vbYes
bState = True
Case vbNo
bState = False
Case vbCancel
End
End Select
With Selection
Set oRng = .Range
With .Find
.ClearFormatting
.Text = "[A-Za-z)][0-9]{1,}"
.MatchWildcards = True
.Wrap = wdFindContinue
.Forward = True
Do While .Execute = True
Set fRng = ActiveDocument.Range(Start:=Selection.Start + 1,
End:=Selection.End) If bState = False Then
If fRng.Start = oRng.End Then Exit Do
If fRng.End = oRng.End Then fRng.End = oRng.End
End If
fRng.Font.Subscript = True
fRng.Collapse Direction:=wdCollapseEnd
Loop
End With
End With
oRng.Select
Set fRng = Nothing
Set oRng = Nothing
Application.ScreenUpdating = True
End Sub
The above macro will search the active document for all numbers
preceded by a letter or a right bracket, and subscript just the
numbers.
If your document has other alphanumeric strings in which a number
follows a letter (eg Table cell references), you'll need to select
only the range(s) containing the text to be converted and answer
'No' to the prompt.


"Graham Mayor" wrote in message
...
Investigate Subscript and Superscript font attributes (CTRL+Shift++
and CTRL+=) If you have lots of chemical formulae to write you may
find - 'Format part of a found text string in a list of items' at
http://www.gmayor.com/word_vba_examples.htm useful --

Graham Mayor - Word MVP

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



sogani wrote:
How to write chemical symbol like Silica (SiO2)



  #7   Report Post  
Posted to microsoft.public.word.docmanagement
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default O2 (Oxegen)

Hi Graham,

The wikipedia article seems to suggest that only ions and isotopes aren't covered by my macro. Covering all possibilities seems
beyond the abilities of a macro - some human intervention will be required, particularly for ions and isotopes.

--
Cheers
macropod
[Microsoft MVP - Word]


"Graham Mayor" wrote in message ...
'Fraid not all - see the examples at http://en.wikipedia.org/wiki/Chemical_formula
--

Graham Mayor - Word MVP

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



macropod wrote:
Hi Graham,

There's always a fly in the ointment, so to speak. AFAIK, most (if
not all) of the chemical formulae numbers that aren't subscripted are
at the start of the formula. My macro leaves those numbers alone.

"Graham Mayor" wrote in message
...
A problem with chemical formulae is that they don't all use
subscript. --

Graham Mayor - Word MVP

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



macropod wrote:
If you have lots of chemical formulae to write you may find -
'Format part of a found text string in a list of items'

Or the following macro, written specifically for chemical formulae:
Sub ChemicalFormatter()
Dim oRng As Range, fRng As Range, bState As Boolean
Application.ScreenUpdating = False
Select Case MsgBox("Do you want to process the whole document?", _
vbYesNoCancel + vbQuestion, "Chemical Formatter")
Case vbYes
bState = True
Case vbNo
bState = False
Case vbCancel
End
End Select
With Selection
Set oRng = .Range
With .Find
.ClearFormatting
.Text = "[A-Za-z)][0-9]{1,}"
.MatchWildcards = True
.Wrap = wdFindContinue
.Forward = True
Do While .Execute = True
Set fRng = ActiveDocument.Range(Start:=Selection.Start + 1,
End:=Selection.End) If bState = False Then
If fRng.Start = oRng.End Then Exit Do
If fRng.End = oRng.End Then fRng.End = oRng.End
End If
fRng.Font.Subscript = True
fRng.Collapse Direction:=wdCollapseEnd
Loop
End With
End With
oRng.Select
Set fRng = Nothing
Set oRng = Nothing
Application.ScreenUpdating = True
End Sub
The above macro will search the active document for all numbers
preceded by a letter or a right bracket, and subscript just the
numbers.
If your document has other alphanumeric strings in which a number
follows a letter (eg Table cell references), you'll need to select
only the range(s) containing the text to be converted and answer
'No' to the prompt.


"Graham Mayor" wrote in message
...
Investigate Subscript and Superscript font attributes (CTRL+Shift++
and CTRL+=) If you have lots of chemical formulae to write you may
find - 'Format part of a found text string in a list of items' at
http://www.gmayor.com/word_vba_examples.htm useful --

Graham Mayor - Word MVP

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



sogani wrote:
How to write chemical symbol like Silica (SiO2)




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:09 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"