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

  • Home
  • SEARCH
  • 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 6199369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:10:32+00:00 2026-05-24T04:10:32+00:00

I have a C# library which has 2 methods. One returns an Integer and

  • 0

I have a C# library which has 2 methods. One returns an Integer and another returns a object[,]

public int ReturnInt()
{
    //Something that return INT
}
public object[,] Return2DArray()
{
    //returns twoDimensionalArrayResponse;
}

Now I am very new to VBA and due to some legacy reasons I need to write a VBA macro rather than VSTO excel Addin to call this Library.

Getting the result from the first meathod was easy. I made the assembly com visible and registered it for Com Interop and then added it as a reference in my VBA project and called it using the code below

Sub GXSData()
    Dim InteropClass As New ExcelInterOpWrapper
    Dim result As Integer
    result = InteropClass.ReturnInt()
    MsgBox "Rows Returned =" & CStr(result)
End Sub

So far , so good. Now I want to call the second method get the data and bind it to excel.

Sounds simple but
–> What type should I use to hold this data. I tried Dynamic array and it did not work
–> How do I bind it to a dynamic range. Let’s say the 2d array is 100*10 I want to bind it to a range something like Range.value = Array I know how to do this in excel addin application in C# but VBA is giving me real problems

Any help on this will be great

  • 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-05-24T04:10:33+00:00Added an answer on May 24, 2026 at 4:10 am

    I have found a way to do this . It is not the perfect approach but works for me for now. Due to my C# skills I wrote the function that will write in excel in C# and simply called it in VBA macro. I am sure there are pure macro ways of doing this , which I would like. This is because I am writing this as an API and MACRO clients will be calling my API. So I would like to have presentation layer in macro. But anyway the C# is here in case it is useful to someone
    The C# method

    public static void BindDataToExcel( Excel.Range range,  object[,] response)
              {
                  int rows = response.GetLength(0);
                  int cols = response.GetLength(1);
                  int n = 0;
                  Excel.Range newRange = range.get_Offset(n, 0).get_Resize(rows - n, cols);
                  newRange.Value = response;
              }
    

    My Macro

    Sub GxsData()
        Dim InteropClass As New ExcelInterOpWrapper 
        Dim o As Object
        Set o = InteropClass.BindDataToExcel(ActiveCell)
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C++ library which I deliver to other developers. One of them
I'm working on a thread library which implement user level threads (i have something
I have a library which has root package scala, and now I have a
I have a very painful library which, at the moment, is accepting a C#
If you have a WPF control library which you wanted to license to developers,
I have two projects, a Cocoa iPhone application and a static library which it
I have a WCF Web Service which is referenced from a class library. After
I have a custom site definition which includes a form library. I have a
I have created a simple wcf service which used the WCF Service Library template.
I have an solution in VS 2008 which contains two class library projects and

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.