Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

not supported property or method, spot the idiot 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hello,

I'm obviously doing something stupid and I can't spot it, please can you tell me why the bookmarks text part higlighted is erroring with property or method is not supported error.

Code:
    'open template and add information pre-merge
    Set wordApp = CreateObject("Word.Application")
    'Open document
    wordApp.Documents.Open cDrive & "\mypath\mydoc.Doc"
    'update bookmark with text
    With wordApp.ActiveDocument
        .Bookmarks("Info").Select
        [b].Selection.TypeText Me!Info[/b]
        'quit / save
        .Quit SaveChanges:=wdSaveChanges, OriginalFormat:=wdWordDocument
    End With
    Set wordApp = Nothing

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
1DMF -

I may be wrong here, but try putting wordApp.Selection.TypeText outside your with block.

I would think that Selection falls under wordApp not ActiveDocument.

Hope this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
who's a clever boy then!!! thank you.

only one problem , it's adding the text each time, I need to overwrite old text with the new text.

How do I do that?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
I read that you needed to replace the bookmark, but i've used the following code and get the same result, it keeps appending the text, not overwriting it.
Code:
Set bmRange = ActiveDocument.Bookmarks("Info").Range

        bmRange.Text = Me!Info

        ActiveDocument.Bookmarks.Add _
        Name:="Info", Range:=bmRange
        
        'quit / save
        wordApp.Quit SaveChanges:=wdSaveChanges, OriginalFormat:=wdWordDocument

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
it's ok i cracked it!

thanks for your help, you did give me the shove i needed to crack the kiddie!!!!

final code...

Code:
'open template and add information pre-merge
    Set wordApp = CreateObject("Word.Application")
    'Open document
    wordApp.Documents.Open cDrive & "\mypath\mydoc.Doc"
    'update bookmark with text
    Set BMRange = ActiveDocument.Bookmarks("Info").Range
    BMRange.Text = Me!Info
    ActiveDocument.Bookmarks.Add "Info", BMRange
    'quit / save
    wordApp.Quit SaveChanges:=wdSaveChanges, OriginalFormat:=wdWordDocument
    Set wordApp = Nothing
    Set BMRange = Nothing

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top