joining code (1 Viewer)

sando

Registered User.
Local time
Today, 13:20
Joined
Jul 7, 2004
Messages
25
OK. I have a macro in a word document I want to add to my access db.
I currently open the word doc and run the macro from Access. I want to add the word doc code to my access code.
Can some one please help. Every time I try to join the two together it locks up access and shuts down.


Access code

---------------------------------------------------
Dim appword As Word.Application
Dim worddoc As Word.Document

Set appword = Word.Application
appword.Visible = False

Set worddoc = appword.Documents.Open("C:\canberrasales.doc")

---------------------------------------------------



My Word Code

---------------------------------------------------

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Date: "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.EndKey Unit:=wdLine
Selection.MoveLeft Unit:=wdWord, Count:=3, Extend:=wdExtend
Selection.Copy
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Product Code"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.InsertColumns
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="Date"
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Paste

'Isert Office Information
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Office: "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=1
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Copy
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Product Code"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.InsertColumns
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="Office"
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Paste

'Convert Table to delimited text
Selection.Tables(1).Select
Selection.Copy
Documents.Add DocumentType:=wdNewBlankDocument
Selection.Paste
Selection.HomeKey Unit:=wdStory
Selection.Tables(1).Select
Selection.Rows.ConvertToText Separator:=wdSeparateByTabs, NestedTables:= _
True
ActiveDocument.SaveAs FileName:="c:\Canberra Sales.txt", FileFormat:= _
wdFormatText, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
ActiveWindow.Close


---------------------------------------------


thanks in advance
 

Users who are viewing this thread

Top Bottom