Solved

Vb.net to C# conversion (late binding problem)

Posted on 2012-03-28
8
345 Views
Last Modified: 2012-06-27
Hi ,

I need the convert the attach module in C#.

The problem is only the 'late binding'.

There is a way to solve this problem ?

Thank You !
ModuloWord.txt
0
Comment
Question by:luca345
  • 4
  • 4
8 Comments
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37776721
can you highlight the section where there is problem???
0
 

Author Comment

by:luca345
ID: 37776764
The atteched module works 100% but I need to convert it in C#.

The problem is

//
1:      ObjWord = CreateObject("Word.Application")
//

and then this:

//
 Public Sub Word_Open(ByRef ObjWord As Object, ByVal FileInput As String)
//

C# don't support  'late binding'.


//  

 Public Sub Word_Open(ByRef ObjWord As Object, ByVal FileInput As String)

        '/////////////////////////////////////////////////////////////
        '/////////// Create Word object and open the file ////////////
        '/////////////////////////////////////////////////////////////

1:      ObjWord = CreateObject("Word.Application")

        ObjWord.Documents.Open(FileInput)

    End Sub

//
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37776787
0
 

Author Comment

by:luca345
ID: 37776805
Hi BuggyCoder,

Convert a code is not a problem.

Here there is a concept that is different from VB.net and C#.

There is not automatic converted that can solve the problem, only a human can solve this.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37776871
well in c# you can use System.VisualBasic namespace and call
var objWord = Interaction.CreateObject("Word.Application") as Word.Application;

see this for reference:-
http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx
0
 

Author Comment

by:luca345
ID: 37776910
Yes teorically is possible but I like to programmin in C# and I don't want use a VB reference.

And apart this when I will try do import it in monoproject vb 'createobject' is not supported.
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37776927
the link that i post in my previous post, tells you how to open word doc from a c# application.
Try to follow and see if it helps....
0
 

Author Closing Comment

by:luca345
ID: 37776964
Thank you !
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now