Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Wed, 07 Dec 2005 13:45:01 +1000,    group: microsoft.public.word.vba.addins        back       


Import all Autotext entries previously exported   
Thankyou all so far for your help. The Export routine worked so well
that now I need to work on an import. The source document contains a two
column table.  The first column is the name for the Autotext entry and
the second is the value.

I can import simple autotext entries using the script I have written
here. The issue is like the import routine, the formating and images are
lost. It is also limited to 255 characters.

Any ideas ?




Sub importAutotextEntries()

   ' Check to see if a table exists in the Active Document
    If ActiveDocument.Tables.Count = 0 Then
        MsgBox "No tables!"
        Exit Sub
    End If
   
    For i = 1 To ActiveDocument.Tables(1).Rows.Count
    
       'first cell is the name for the new Autotext entry - Minus the
Paragraph mark
       newname = ActiveDocument.Tables(1).Rows(i).Cells(1)
       namelength = Len(newname)
       namelength = namelength - 2
       finalname = Left(newname, namelength)
       NormalTemplate.AutotextEntries.Add Name:=finalname,
Range:=Selection.Range
       
       'Second cell is the value for the new Autotext entry - Minus the
Paragraph mark
       newvalue = ActiveDocument.Tables(1).Rows(i).Cells(2)
       valuelength = Len(newvalue)
       valuelength = valuelength - 2
       finalvalue = Left(newvalue, valuelength)
       NormalTemplate.AutotextEntries(finalname).Value = finalvalue

    Next i

End Sub
-- 
Regards,

Michael Jenkin
MCP MVP SBS
Australia

www.mickyj.com
date: Wed, 07 Dec 2005 13:45:01 +1000   author:   Michael Jenkin [SBS-MVP]

Re: Import all Autotext entries previously exported   
There seems to be no "value" parameter to add and the insert setting
seems to be the only way to use richtext.

Any ideas ?

Michael Jenkin [SBS-MVP] wrote:

> Thankyou all so far for your help. The Export routine worked so well
> that now I need to work on an import. The source document contains a two
> column table.  The first column is the name for the Autotext entry and
> the second is the value.
> 
> I can import simple autotext entries using the script I have written
> here. The issue is like the import routine, the formating and images are
> lost. It is also limited to 255 characters.
> 
> Any ideas ?
> 
> 
> 
> 
> Sub importAutotextEntries()
> 
>    ' Check to see if a table exists in the Active Document
>     If ActiveDocument.Tables.Count = 0 Then
>         MsgBox "No tables!"
>         Exit Sub
>     End If
>    
>     For i = 1 To ActiveDocument.Tables(1).Rows.Count
>     
>        'first cell is the name for the new Autotext entry - Minus the
> Paragraph mark
>        newname = ActiveDocument.Tables(1).Rows(i).Cells(1)
>        namelength = Len(newname)
>        namelength = namelength - 2
>        finalname = Left(newname, namelength)
>        NormalTemplate.AutotextEntries.Add Name:=finalname,
> Range:=Selection.Range
>        
>        'Second cell is the value for the new Autotext entry - Minus the
> Paragraph mark
>        newvalue = ActiveDocument.Tables(1).Rows(i).Cells(2)
>        valuelength = Len(newvalue)
>        valuelength = valuelength - 2
>        finalvalue = Left(newvalue, valuelength)
>        NormalTemplate.AutotextEntries(finalname).Value = finalvalue
> 
>     Next i
> 
> End Sub
> 

-- 
Regards,

Michael Jenkin
MCP MVP SBS
Australia

www.mickyj.com
date: Wed, 07 Dec 2005 14:43:49 +1000   author:   Michael Jenkin [SBS-MVP]

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us