Results 1 to 5 of 5

Thread: [RESOLVED] How to use spread sheet 'ClearContents'

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2017
    Posts
    79

    Resolved [RESOLVED] How to use spread sheet 'ClearContents'

    Is it correct

    Set excelWSO = excelWBO.Worksheets(1)
    excelWBO.UsedRange.ClearContents

    why the usedrange not working in my case.

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: How to use spread sheet 'ClearContents'

    I'll refer this to the Moderators so they can shift it over to the Office Development portion of this Forum for you.

    Sam

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2017
    Posts
    79

    Re: How to use spread sheet 'ClearContents'

    I like to add here that as in the code i am using Data Report

    DataReport.Show vbModal, Me

    ' Then using following line for clearing up the excel spread sheet that being linked to data report.

    excelWSO.UsedRange.ClearContents
    excelWSO.UsedRange.Delete
    excelWSO.UsedRange.Clear

    ' Nothing happening and the message " wrong method used" appears when mouse pointed there on .Range function ... I think as DataReport used the spread sheet it still opened and hence uneditable. My be my guess wrong.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2017
    Posts
    79

    Re: How to use spread sheet 'ClearContents'

    Yes its true. Its Data Report creating problem. I just added the line after datareport

    DataEnvironment.Connection.Close

    Solved.....

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

    Re: [RESOLVED] How to use spread sheet 'ClearContents'

    it may be better to use a disconnected recordset for your data report, rather than an excel sheet
    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

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