Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8712527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:07:40+00:00 2026-06-13T05:07:40+00:00

Error: The field, constructor or member ‘UsedRange’ is not defined. Code excerpts: open Microsoft.Office.Interop.Excel

  • 0

Error: “The field, constructor or member ‘UsedRange’ is not defined”.

Code excerpts:

open Microsoft.Office.Interop.Excel
open Microsoft.Office.Tools.Excel // Onorio's excellent suggestion didn't fix code until this line was added.
// Once the above line was added, Onorio's suggestion worked,
// but now F# says "The field, constructor or member 'EntireColumn' is not defined".

let xl = ApplicationClass()
xl.Workbooks.OpenText(...
let wb = xl.Workbooks.Item(1)
let ws = wb.ActiveSheet :?> Worksheet // Per Onorio's suggestion.

ws.UsedRange.EntireColumn.AutoFit()
// "The field, constructor or member 'EntireColumn' is not defined".

// Here's another example of UsedRange now working,
// but Properties and Methods of UsedRange not working:
// (uniqueID is simply a Boolean set earlier based on ini file values)
if uniqueID then
   xl.Range("A1").EntireColumn.Insert() |> ignore
   xl.Range("A1").Value <- "UniqueID"
   xl.Range("A2").Value <- 1
   xl.Range("A2").AutoFill(xl.Range("A2:A" + ws.UsedRange.Rows.Count),
                           XlAutoFillType.xlFillSeries) |> ignore
// Here it's "The field, constructor or member 'Rows' is not defined".

Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:07:43+00:00Added an answer on June 13, 2026 at 5:07 am

    Try adding this:

    let wb = xl.Workbooks.Item(1)
    let actSheet = wb.ActiveSheet :?> Worksheet  //downcast obj to Worksheet
    actSheet.UsedRange.EntireColumn.AutoFit()
    

    wb.ActiveSheet returns an “obj” and you need to downcast it to a Worksheet in order for the UsedRange method to resolve correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to use F# read a xls file as below open Microsoft.Office.Interop.Excel let
Error - Market cannot be resolved or is not a field. News cannot be
The code below is giving me the error: column 'id' in field list is
In the code below: DbModels.prototype.updateById = function(_collection, id, field, value, callback) { this.getCollection(_collection, function(error,
How to inject final member in Activity without getting the blank final field error?
I am getting the error A field initializer cannot reference the nonstatic field, While
Rails displays all validation error messages associated with a given field. If I have
I am getting an error An object reference is required for the non-static field,
in a form if there is a field and a global error both messages
I have a form field: web_address = forms.RegexField(regex=r'^DO SOMETHING$', error_messages = {'invalid': _(Not a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.