473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

creating word document using vb6.0

Hi
I am doing a small project in vb.I want to create a word document consisting values in table format.The values are to be taken from the excel files.This is to be done using VB.The word file format will be fixed.So please can anybody help me with the Word VB Excel connectivity as soon as possible.
Apr 18 '07 #1
1 10943
SammyB
807 Expert 512MB
Hi
I am doing a small project in vb.I want to create a word document consisting values in table format.The values are to be taken from the excel files.This is to be done using VB.The word file format will be fixed.So please can anybody help me with the Word VB Excel connectivity as soon as possible.
This should get you started. --Sam
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Private Sub Command1_Click()
  3.     ' Use Project, References menu to add
  4.     ' Microsoft Word & Excel Object Libraries
  5.     Const XL_DOC As String = "N:\Programming\Word\WordTable\InputData.xls"
  6.     Const WD_DOC As String = "N:\Programming\Word\WordTable\ReadMe.doc"
  7.     Dim xlApp As New Excel.Application
  8.     Dim xlBook As Excel.Workbook
  9.     Dim wdApp As New Word.Application
  10.     Dim wdDoc As Word.Document
  11.     Dim wdTable As Word.Table
  12.  
  13.     Set xlBook = xlApp.Workbooks.Open(FileName:=XL_DOC, ReadOnly:=True)
  14.     xlApp.Visible = True
  15.     Set wdDoc = wdApp.Documents.Add
  16.     wdApp.Visible = True
  17.     Set wdTable = wdDoc.Tables.Add(Range:=wdApp.Selection.Range, _
  18.         NumRows:=2, NumColumns:=4, DefaultTableBehavior:=wdWord9TableBehavior, _
  19.         AutoFitBehavior:=wdAutoFitFixed)
  20.     With xlBook.Worksheets("Sheet1")
  21.         wdTable.Cell(1, 1).Range.Text = .Cells(1, 1).Text
  22.         wdTable.Cell(1, 2).Range.Text = .Cells(1, 2).Text
  23.     End With
  24.     'xlApp.Quit
  25.     wdDoc.SaveAs FileName:=WD_DOC
  26.     'wdDoc.Quit
  27. End Sub
Apr 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Kerri McDonald | last post by:
We have an application where the user fills out many screens and when they are done, we are supposed to display the text they entered in a word or excel format. That is fairly easily accomplished...
7
by: Zeke | last post by:
I'm using the following code to create word document but the problem is if you go to task manager you'll see a WINWORD.EXE process is running but not the application, here is the code: ...
0
by: volume | last post by:
Hi all, In an effort to try to impress the boss, I would like to log accounting information to an Excel spreadsheet using C# and .NET. This would be a mockup only, not a real solution - yet! We...
4
by: Nikhil Patel | last post by:
Hi all, I need to generate a word document and save it on the server from an ASP.Net application. Basically I want to load a word template and insert some field values from a dataset and save...
3
by: m3ckon | last post by:
Hi there, I can succesfully create a word doc from my asp.net page, but I have 2 issues I need to resolve in order to use it in my app: 1) Creating a table: I seem unable to create a table,...
1
by: Novice | last post by:
Hi all, I'm using C# in my ASP.NET application and cannot seem to access the MS word libraries to create a word document for some reason. I have used both of these tutorials:...
0
by: goof1972 | last post by:
Hello All, I have a VB.NET web application (1.1 framework) that creates a new Word document through interop.word.dll. I have a Windows Server 2003 with Office XP Professional installed. I've...
2
by: tamaker | last post by:
I have a registration form where a user is able to, upon submission of the form, have their submission entered into a simple database... now Im looking to create a word document on the fly from...
0
by: PracticalApps | last post by:
I looked to find a canned solution to create a Word document in my application and just couldn't find anything that just gets to the point. I would think, and I may be making too strong of an...
2
by: uamusa | last post by:
I am Dynamically generating a proposal(report) in MS Word. By default the Paragraph Alignment is "Left". For the First 6 Paragraphs I set the Alignment to "Center", and then when attempting to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.