Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

word, excel file creation without attaching reference dll

Posted on 2009-05-15
3
Medium Priority
?
725 Views
Last Modified: 2013-11-27
right click on the windows desktop shows a menu "New". anyone can create new file like word, excel, access etc by selecting the corresponding file type. i am writing code in vb.net 2008 express edition. i wantto create various files like that interface. i want to create exs. xtsx, doc, docx etc. through my code. everywhere i found i have to add the corresponding old/tlb files or dll for excel, word etc. but in my development PC office 2007 is there, but in client PC office 2003 may be there. so i can not attach that reference as it will not work in those pc. any suggestion for this problem? can i create doc/docx, xls/xlsx files without adding the reference in my code? thanx in advance. I tried the following code, but creation of docx generates problem in that process, the docx is creating but not opening by that method. any alternative?
Dim fs As New FileStream(gsParent2FullPath & "\" & gnodCurrent.FullPath & "\" & InFileName, FileMode.CreateNew, FileAccess.ReadWrite)
                fs.Close()

Open in new window

0
Comment
Question by:Amitava_Mukherjee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Expert Comment

by:prashantagarw10
ID: 24394934
Hi,
You have following options :
1. Check dynamically at run time if the user has office 2007 or higher or not. If found then create the docx/xlsx file as per current code otherwise create the doc/xls file.
2. If you do not want to attach any refrence tlb or dll in your installer then include a template files for doc/docx/xls/xlsx in the installer of your application. On user selecting to create a file create  a copy of your template file to user defined location and name and format(doc or docx). In this even if user does not have any installation then also he can create a office file.

Cheers!!!
0
 
LVL 16

Accepted Solution

by:
ToddBeaulieu earned 2000 total points
ID: 24394971
This sounds awfully familiar. I ran into something similar a few years back. I wrote an application that used Excel and had references to it, but users had different versions.

I know at one point, I used hard references during the development cycle, but then removed them and replaced the office-specific variables with "object" variables, and the "new {specific class}" statements with "CreateObject("Excel.WorkBook")" statements. This let me use Intellisense during development, but switch to late binding for the user.

I *believe* you can also develop on a machine with the lowest version of office in use and it will work with newer versions at runtime (forward compatible, not backward compatible).

But I think the first technique is probably the best way to do it.
0
 

Author Closing Comment

by:Amitava_Mukherjee
ID: 31581868
Thanx, nice solution
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

610 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