dhanya_piit 0 Newbie Poster
Dim MyWord As Word.Application
Dim WordDoc As Word.Document
Dim MyRange As Word.Range
Dim MyTable As Word.Table
Dim MyCell As Word.Cell
Dim MyCells As Word.Cells
Dim MyCols As Word.Columns
Dim RetSt As String
Dim Pic As String
Dim arc As String

RetSt1 = Chr(10) + Chr(13)
RetSt2 = Chr(13) + Chr(10)
RetSt = Chr(13)
arc = worddocname.Text
'newfile$ = App.Path + arc.doc
newfile$ = App.Path + "\" + arc + ".doc"
Set MyWord = CreateObject("Word.Application")
Set WordDoc = MyWord.Documents.Add

MyWord.Visible = True
MyWord.Activate

MyWord.Selection.Font.Name = "Timesnew roman"
MyWord.Selection.Font.Size = 12
a1$ = "IRREVOCABLE  CONSENT  LETTER" + RetSt
MyWord.Selection.Font.Bold = True
MyWord.Selection.Font.Underline = wdUnderlineSingle
MyWord.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
MyWord.Selection.TypeText a1$
MyWord.Selection.Font.Underline = wdUnderlineNone
MyWord.Selection.TypeText RetSt
MyWord.Selection.TypeText RetSt

MyWord.Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
a1$ = Form5.Label1.Caption + "  " + Form5.ROOMNO.Text + RetSt
MyWord.Selection.TypeText a1$
MyWord.Selection.TypeText RetSt

a1$ = Form5.Label2.Caption + "  " + Form5.FullName.Text + RetSt
MyWord.Selection.TypeText a1$
MyWord.Selection.TypeText RetSt

a1$ = Form5.Label3.Caption + "  " + Form5.Address.Text + RetSt
MyWord.Selection.TypeText a1$
MyWord.Selection.TypeText RetSt
MyWord.Selection.TypeText RetSt
MyWord.Selection.TypeText RetSt

MyWord.Selection.Font.Bold = False
MyWord.Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify

a1$ = "             I  the undersigned " + Form5.FullName.Text + " is a bonafied member " + RetSt
MyWord.Selection.TypeText a1$
MyWord.Selection.TypeText RetSt
'Label5.Caption = " of  " & Form5.society.Text & " co-operative housing society (proposed) subject to"

a1$ = " of " + Form5.society.Text + " co-operative housing society (proposed)subject to"
MyWord.Selection.TypeText a1$
MyWord.Selection.TypeText RetSt
MyWord.Selection.TypeText RetSt
'Label6.Caption = "eligibility being approved. I have willingly participated in this redevelopment "

a1$ = "eligibility being approved. I have willingly participated in this redevelopment "
MyWord.Selection.TypeText a1$
MyWord.Selection.TypeText RetSt
MyWord.Selection.TypeText RetSt
'"scheme under " & Form5.Option4.Caption & " " & Form5.Option5.Caption & ".  I have given my consent willingly "

a1$ = "scheme under " + Form5.Option4.Caption + Form5.Option5.Caption + " I have given my consent willingly  "
MyWord.Selection.TypeText a1$
MyWord.Selection.TypeText RetSt
MyWord.Selection.TypeText RetSt
'Label9.Caption = "to Paradise Construction Company, " & Form5.Option2.Caption & "" & Form5.Option1.Caption & "" & Form5.Option3.Caption & "  for development"

a1$ = " to Paradise Construction Company." + Form5.Option2.Caption + Form5.Option1.Caption + Form5.Option3.Caption + "  for development "
MyWord.Selection.TypeText a1$
MyWord.Selection.TypeText RetSt
MyWord.Selection.TypeText RetSt
'"and I will abide by all the rules and regulations of the redevelopment"

a1$ = "and I will abide by all the rules and regulations of the redevelopment."
MyWord.Selection.TypeText a1$
MyWord.Selection.TypeText RetSt
MyWord.Selection.TypeText RetSt

a1$ = "scheme. My thumb impression and signature is appeared below."
MyWord.Selection.TypeText a1$
MyWord.Selection.TypeText RetSt
MyWord.Selection.TypeText RetSt
MyWord.Selection.TypeText RetSt


'insert pic
Set objShape = MyWord.Selection.InlineShapes.AddPicture(Form5.PHOTOGRAPH.Text)
objShape.Borders.OutsideLineStyle = wdLineStyleSingle

a1$ = "       "
MyWord.Selection.TypeText a1$


Set objShape = MyWord.Selection.InlineShapes.AddPicture(Form5.FINGERPRINT.Text)
objShape.Borders.OutsideLineStyle = wdLineStyleSingle
MyWord.Selection.TypeText RetSt
a1$ = "         PHOTOGRAPH                                " + " FINGERPRINT                               " + " SIGNATURE          "
MyWord.Selection.TypeText a1$



MyWord.Selection.GoToNext wdGoToLine

'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

'finaly save the file. If the document exists then will be overwriten
WordDoc.SaveAs newfile$

Set WordDoc = Nothing
Set MyWord = Nothing

i have this following piece of code
i create a word document with the name asked to the user
my requirement here is when an user enters the name with which the document is to b save it should check the current folder to see whether a document with same name exists or not.......

plz help asap

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.