Results 1 to 5 of 5

Thread: No Such Interface Supported

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2012
    Location
    Nottingham, UK
    Posts
    44

    Exclamation No Such Interface Supported

    Hi, I am trying to replace styles in a document (doc or docx) with styles from a template document (dotx). I've imported the dotx into the document with

    Code:
    Globals.ThisAddIn.Application.ActiveDocument.CopyStylesFromTemplate(Template:=DirectoryForRestyler & cbxNewStyleSheets.SelectedItem.ToString & ".dotm")
    so that all the styles needed exist in the document. I then have a CustomTaskPane where the user selects the old style from the document by range, and replaces it with a new style.

    Name:  l37y8DOa.png
Views: 616
Size:  22.9 KB

    When they click Replace Styles, I'm getting this

    Name:  sLtybSzS.jpg
Views: 674
Size:  34.6 KB

    Code:
     No such interface supported
    
    No such interface supported
    
      at Microsoft.Office.Interop.Word.Range.set_Style(Object& prop)
       at <application>.Button1_Click(Object sender, EventArgs e) in <redacted>.vb:line 77
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    It's got me at a complete roadblock and I don't know how to progress. Looking at the microsoft docs, it states I should be able to set the style, so I'm not sure where I am going wrong.

    https://docs.microsoft.com/en-us/off...rd.range.style

    If you need any more details, I can provide them. Help would be appreciated. Thanks.
    Last edited by TheMeq; May 17th, 2019 at 05:34 AM.
    ~ TheMeq ~
    If I helped in anyway, please hit the star and send me some rep! Thanks

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: No Such Interface Supported

    I've imported the dotx into the document with
    can you then use the imported styles if you change the style manually?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2012
    Location
    Nottingham, UK
    Posts
    44

    Re: No Such Interface Supported

    Quote Originally Posted by westconn1 View Post
    can you then use the imported styles if you change the style manually?
    Yes, I am able to use the styles manually by selecting them from Home > Styles.
    ~ TheMeq ~
    If I helped in anyway, please hit the star and send me some rep! Thanks

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: No Such Interface Supported

    does styletosetto contain a valid style object?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2012
    Location
    Nottingham, UK
    Posts
    44

    Re: No Such Interface Supported

    Quote Originally Posted by westconn1 View Post
    does styletosetto contain a valid style object?
    Name:  Capture.jpg
Views: 578
Size:  17.2 KB

    This is what I have, I noticed that the type is different but not sure how to get around this.

    + par.Range.Style {System.__ComObject} Object {System.__ComObject}
    + styleToSetTo {System.__ComObject} Microsoft.Office.Interop.Word.Style {System.__ComObject}
    ~ TheMeq ~
    If I helped in anyway, please hit the star and send me some rep! Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width