Using code from word

honor401

Registered User.
Local time
Yesterday, 19:52
Joined
Aug 26, 2004
Messages
11
I have this code that I have moved from word to access.
Sub formatndc()
'
' formatndc Macro
' Macro recorded 9/7/2004 by honor401
'
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "+777+"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ChangeFileOpenDirectory "C:\Program Files\Ripple\"
ActiveDocument.SaveAs FileName:="testing.txt", FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, Encoding:=20127, InsertLineBreaks:=False, AllowSubstitutions:= _
False, LineEnding:=wdCRLF
End Sub

I would like to use this code to format a document that will always be at c:\testing.doc
I am new to coding and would like to stop using a "call shell" command and just format from within access.

thanks in advance for the help.
Honor401
 
In your access procedure you write:

Code:
Dim oWord As Object

'Open an unvisible instance of Word
Set oWord = CreateObject("Word.Application")

With oWord
    .Documents.Open "c:\testing.doc"
    ....
    ....   'Here insert your code from word, 
           'but don't forget the "leading" dot!


Hope that will help.

Friendly regards

Agnostiker
 

Users who are viewing this thread

Back
Top Bottom