|
Hi! All,
Please help me how to generate XML file in VB6 using a view from the database?
Thanks and Regards,
Virendra
|
|
|
|
|
I am developing ASP.NET Web Application using vb.net One of
the requriement of this application is ...when user submit
the Web Form....it should open the Word Templete and
insert the values into that templete...
Does anybody knows...How to Open and Writes into Word
Document Using ASP.NET and vb.net Directly...i am looking for
specific sample...
Thanks,
-- modified at 8:43 Wednesday 4th July, 2007
|
|
|
|
|
hello frnd,
do u want to open the already saved file if yes try the following
first add the COM reference, if you have word 2000 then add
microsoft word object library 9.0 and if you have word 2003 then do add microsoft word object library 11.0
and then code as,
imports word = microsoft.office.interop.word
dim objApp as new word.application
dim objDoc as new word.document
objDoc = objApp.documents.open("\\Address Of Blank Word File")
objdoc.visible = true
and after writing content to file the user close the file
By this code ; Already stored file open and displayed
AND If you want to open the new file then
dim objApp as new word.application
dim objDoc as new word.document
objDoc = objApp.documents.add("\\Address Of Blank Word File where u want to create")
objdoc.visible = true
in both the case the user must write and save the document
regards,
koolprasad2003
If the message is useful for U then please Rate This message...
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Ours is a web application and we get the error....."Message filter indicates that the application is busy..."
Please help...we need this urgently
Thanks,
Suresh
|
|
|
|
|
have you tried what i told....
working with word automation is easy...
regards,
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
this is our code....
It works in a windows application but not in a web application....please try it out and help..
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(336, 176)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(576, 470)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Dim wrdApp As Word.Application
Dim wrdDoc As Word._Document
Private Sub InsertLines(ByVal LineNum As Integer)
Dim iCount As Integer
' Insert "LineNum" blank lines.
For iCount = 1 To LineNum
wrdApp.Selection.TypeParagraph()
Next iCount
End Sub
Private Sub FillRow(ByVal Doc As Word.Document, ByVal Row As Integer, _
ByVal Text1 As String, ByVal Text2 As String, _
ByVal Text3 As String, ByVal Text4 As String)
With Doc.Tables.Item(1)
' Insert the data in the specific cell.
.Cell(Row, 1).Range.InsertAfter(Text1)
.Cell(Row, 2).Range.InsertAfter(Text2)
.Cell(Row, 3).Range.InsertAfter(Text3)
.Cell(Row, 4).Range.InsertAfter(Text4)
End With
End Sub
Private Sub CreateMailMergeDataFile()
Dim wrdDataDoc As Word._Document
Dim iCount As Integer
' Create a data source at C:\DataDoc.doc containing the field data.
wrdDoc.MailMerge.CreateDataSource(Name:="C:\DataDoc.doc", _
HeaderRecord:="FirstName, LastName, Address, CityStateZip")
' Open the file to insert data.
wrdDataDoc = wrdApp.Documents.Open("C:\DataDoc.doc")
For iCount = 1 To 2
wrdDataDoc.Tables.Item(1).Rows.Add()
Next iCount
' Fill in the data.
FillRow(wrdDataDoc, 2, "Steve", "DeBroux", _
"4567 Main Street", "Buffalo, NY 98052")
FillRow(wrdDataDoc, 3, "Jan", "Miksovsky", _
"1234 5th Street", "Charlotte, NC 98765")
FillRow(wrdDataDoc, 4, "Brian", "Valentine", _
"12348 78th Street Apt. 214", "Lubbock, TX 25874")
' Save and close the file.
wrdDataDoc.Save()
wrdDataDoc.Close(False)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim wrdSelection As Word.Selection
Dim wrdMailMerge As Word.MailMerge
Dim wrdMergeFields As Word.MailMergeFields
Dim StrToAdd As String
' Create an instance of Word and make it visible.
wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
' Add a new document.
wrdDoc = wrdApp.Documents.Add()
wrdDoc.Select()
wrdSelection = wrdApp.Selection()
wrdMailMerge = wrdDoc.MailMerge()
' Create MailMerge Data file.
CreateMailMergeDataFile()
' Create a string and insert it in the document.
StrToAdd = "State University" & vbCr & _
"Electrical Engineering Department"
wrdSelection.ParagraphFormat.Alignment = _
Word.WdParagraphAlignment.wdAlignParagraphCenter
wrdSelection.TypeText(StrToAdd)
InsertLines(4)
' Insert merge data.
wrdSelection.ParagraphFormat.Alignment = _
Word.WdParagraphAlignment.wdAlignParagraphLeft
wrdMergeFields = wrdMailMerge.Fields()
wrdMergeFields.Add(wrdSelection.Range, "FirstName")
wrdSelection.TypeText(" ")
wrdMergeFields.Add(wrdSelection.Range, "LastName")
wrdSelection.TypeParagraph()
wrdMergeFields.Add(wrdSelection.Range, "Address")
wrdSelection.TypeParagraph()
wrdMergeFields.Add(wrdSelection.Range, "CityStateZip")
InsertLines(2)
' Right justify the line and insert a date field
' with the current date.
wrdSelection.ParagraphFormat.Alignment = _
Word.WdParagraphAlignment.wdAlignParagraphRight
wrdSelection.InsertDateTime( _
DateTimeFormat:="dddd, MMMM dd, yyyy", _
InsertAsField:=False)
InsertLines(2)
' Justify the rest of the document.
wrdSelection.ParagraphFormat.Alignment = _
Word.WdParagraphAlignment.wdAlignParagraphJustify
wrdSelection.TypeText("Dear ")
wrdMergeFields.Add(wrdSelection.Range, "FirstName")
wrdSelection.TypeText(",")
InsertLines(2)
' Create a string and insert it into the document.
StrToAdd = "Thank you for your recent request for next " & _
"semester's class schedule for the Electrical " & _
"Engineering Department. Enclosed with this " & _
"letter is a booklet containing all the classes " & _
"offered next semester at State University. " & _
"Several new classes will be offered in the " & _
"Electrical Engineering Department next semester. " & _
"These classes are listed below."
wrdSelection.TypeText(StrToAdd)
InsertLines(2)
' Insert a new table with 9 rows and 4 columns.
wrdDoc.Tables.Add(wrdSelection.Range, NumRows:=9, _
NumColumns:=4)
With wrdDoc.Tables.Item(1)
' Set the column widths.
.Columns.Item(1).SetWidth(51, Word.WdRulerStyle.wdAdjustNone)
.Columns.Item(2).SetWidth(170, Word.WdRulerStyle.wdAdjustNone)
.Columns.Item(3).SetWidth(100, Word.WdRulerStyle.wdAdjustNone)
.Columns.Item(4).SetWidth(111, Word.WdRulerStyle.wdAdjustNone)
' Set the shading on the first row to light gray.
.Rows.Item(1).Cells.Shading.BackgroundPatternColorIndex = _
Word.WdColorIndex.wdGray25
' Bold the first row.
.Rows.Item(1).Range.Bold = True
' Center the text in Cell (1,1).
.Cell(1, 1).Range.Paragraphs.Alignment = _
Word.WdParagraphAlignment.wdAlignParagraphCenter
' Fill each row of the table with data.
FillRow(wrdDoc, 1, "Class Number", "Class Name", "Class Time", _
"Instructor")
FillRow(wrdDoc, 2, "EE220", "Introduction to Electronics II", _
"1:00-2:00 M,W,F", "Dr. Jensen")
FillRow(wrdDoc, 3, "EE230", "Electromagnetic Field Theory I", _
"10:00-11:30 T,T", "Dr. Crump")
FillRow(wrdDoc, 4, "EE300", "Feedback Control Systems", _
"9:00-10:00 M,W,F", "Dr. Murdy")
FillRow(wrdDoc, 5, "EE325", "Advanced Digital Design", _
"9:00-10:30 T,T", "Dr. Alley")
FillRow(wrdDoc, 6, "EE350", "Advanced Communication Systems", _
"9:00-10:30 T,T", "Dr. Taylor")
FillRow(wrdDoc, 7, "EE400", "Advanced Microwave Theory", _
"1:00-2:30 T,T", "Dr. Lee")
FillRow(wrdDoc, 8, "EE450", "Plasma Theory", _
"1:00-2:00 M,W,F", "Dr. Davis")
FillRow(wrdDoc, 9, "EE500", "Principles of VLSI Design", _
"3:00-4:00 M,W,F", "Dr. Ellison")
End With
' Go to the end of the document.
wrdApp.Selection.GoTo(Word.WdGoToItem.wdGoToLine, _
Word.WdGoToDirection.wdGoToLast)
InsertLines(2)
' Create a string and insert it into the document.
StrToAdd = "For additional information regarding the " & _
"Department of Electrical Engineering, " & _
"you can visit our Web site at "
wrdSelection.TypeText(StrToAdd)
' Insert a hyperlink to the Web page.
wrdSelection.Hyperlinks.Add(Anchor:=wrdSelection.Range, _
Address:="http://www.ee.stateu.tld")
' Create a string and insert it in the document.
StrToAdd = ". Thank you for your interest in the classes " & _
"offered in the Department of Electrical " & _
"Engineering. If you have any other questions, " & _
"please feel free to give us a call at " & _
"555-1212." & vbCr & vbCr & _
"Sincerely," & vbCr & vbCr & _
"Kathryn M. Hinsch" & vbCr & _
"Department of Electrical Engineering" & vbCr
wrdSelection.TypeText(StrToAdd)
' Perform mail merge.
wrdMailMerge.Destination = _
Word.WdMailMergeDestination.wdSendToNewDocument
wrdMailMerge.Execute(False)
' Close the original form document.
wrdDoc.Saved = True
wrdDoc.Close(False)
' Release References.
wrdSelection = Nothing
wrdMailMerge = Nothing
wrdMergeFields = Nothing
wrdDoc = Nothing
wrdApp = Nothing
' Clean up temp file.
System.IO.File.Delete("C:\DataDoc.doc")
End Sub
End Class
|
|
|
|
|
Dear Suresh,
let me suggest U a simplest and finest way,
open a word file, record a macro and do the events u wants,
and stop the macro and Press Alt+F11
copy the code in VB Project and open that project using .Net it will gives you a code..
regards,
koolprasad2003
If the message is useful for U then please Rate This message...
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
i worked with macros also it's not working
can please help me. if u have code for creating word document.
Dim w As New Word.Application
Dim d As Word.Document
d = w.Documents.Open("c:\test1.doc")
'w.Selection.MoveRight(Unit:=1, count:=6)
d.MailMerge.OpenDataSource(Name:="C:\test1.csv", ReadOnly:=False, LinkToSource:=True, Connection:="", SQLStatement:="", SQLStatement1:="")
d.Fields.Add(Range:=w.Selection.Range, Type:=Word.WdFieldType.wdFieldMergeField, Text:="""LastName""")
With d.MailMerge
.Destination = Word.WdMailMergeDestination.wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = Word.WdMailMergeDefaultRecord.wdDefaultFirstRecord
.LastRecord = Word.WdMailMergeDefaultRecord.wdDefaultLastRecord
End With
.Execute(Pause:=False)
End With
w.Visible = True
|
|
|
|
|
hello guys
I have the following code:
Dim lineArray As String() = ProcessBuffer.ToString.Split(ControlChars.Cr)
Dim lineArrayList As ArrayList = ArrayList.Adapter(lineArray)
I use the Adapter method to convert my array to an arraylist, what is far more easy to work in my program.
Now when i want to remove a index I get this exception.
Unhandled Exception: System.NotSupportedException: Collection was of a fixed size.
at System.Array.System.Collections.IList.RemoveAt(Int32 index)
at System.Collections.IListWrapper.RemoveAt(Int32 index)
Anyone an idea how to avoid this problem without using a manual copy of all the elements into the arraylist. Because it seems that the arraylist gets a fixed size. :-/
|
|
|
|
|
try using the ArrayList(ICollection) constructor, that one copies the items for you.
|
|
|
|
|
Thanks for the answer.
I was checking ArrayList(ICollection) and I can't figure it out how it works, what i do, the same problem appears. Can you help me by putting me in the right direction?
Thanks.
|
|
|
|
|
Hi,
this is C# code that works; it prints 5 and 6
ArrayList list;
int[] arr=new int[]{1,2,3,4,5};
list=new ArrayList(arr);
log("count="+list.Count);
list.Add(6);
log("count="+list.Count);
If I am not mistaken, the crucial line translates to VB.NET as:
list=New ArrayList(arr)
|
|
|
|
|
Thanks that does the job. Now I can delete what I want without having problems.
|
|
|
|
|
Guys & Gals
i Was playing around with the screens .
Was wondering if i can use logo and have it revolving around the programs main form. How can i archive this?
|
|
|
|
|
Your question doesn't make a whole lot of sense. You can draw anything you like on your forms. Where do you want to draw it ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
think he want it to orbit around his form, passing in front and behind, maybe direct him to the graphics forum.
Posted by The ANZAC : "WWBD, What Would Buffy Do?" : "I don't know man, she's stronger than me"
|
|
|
|
|
OK - he wants WPF then.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
try the graphics forum.
Posted by The ANZAC : "WWBD, What Would Buffy Do?" : "I don't know man, she's stronger than me"
|
|
|
|
|
I m using Visual Studio 2005. How can I drag and Drop Table From Data Connection Node of Server Explorer to Form. I have done it n Visual Studio 2003. But I m not able to do this in 2005. Does VS 2005 does not support it, or ther s a special method for that.
Thanks in Advance.
|
|
|
|
|
It works exactly the same. So long as you can see the table in the Server Explorer and can hold the mouse button down on it and drag it over to the form. Are you getting a circle with a line through it when you try to drag the table over to the form?
|
|
|
|
|
Yes I get a circle with a line through it when I try to drag the table over to the form.
|
|
|
|
|
There are only two ways I've seen this happen. The first is when you try to drag the table to the code view of the form. It will only work if you drop it on the design view of the form. And the second is if the form's controls are locked. Click on the form to select it in design view, right-click on it and you should see an option for "Lock Controls". This should not have a check mark next to it.
|
|
|
|
|
Wait a minute. It just occured to me, you're dragging this table from Server Explorer? That won't work. You have to create a Data Connection to the database, open up the database on the Data Sources tab, then drag to table from there.
|
|
|
|
|
Hello There
I have one requirement where I have to transfer the file from one machine to another. Client is ready to accept the application installed on both ends. I dont understand which technology is the best one to transfer the file. (File size could be 1 mb to 1 GB) like one is remoting .. Please suggest me any thing or send me some link for code help if any ?
Thanks
|
|
|
|
|
This can be done any number of ways. Do you need security? Can you use an existing file transfer method, like FTP?
You can use Remoting. You can write your own socket-based client/server over TCP/IP, a web service would work. There's a bunch of different methods. For examples, all you have to do is Google for something like "VB.NET ftp send file".
|
|
|
|
|