SunQuest
 
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old July 25th, 2004, 11:58 PM
sando sando is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 sando User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Access XP & Word

OK. I have posted this on Access General, but I thought I might try here as well.


I have a word document with a macro in it.
I can open the Word document and run the macro from access,
But I want to incorperate this macro into my access db.
When I do this Access packs it in.
I know there is something wrong but can't find it.
Keeping in mind this works when it is in the word document.

Thank you in advance. I'm sure someone out there can help me.

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

Dim str As String
Set appword = New Word.Application
appword.Visible = True
Set worddoc = appword.Documents.Open("C:\canberrasales.doc")
With appword

.Selection.HomeKey unit:=wdStory
.Selection.Find.ClearFormatting
With .Selection
.Find.Text = "Date: "
.Find.Replacement.Text = ""
.Find.Forward = True
.Find.Wrap = wdFindContinue
.Find.Format = False
.Find.MatchCase = False
.Find.MatchWholeWord = False
.Find.MatchWildcards = False
.Find.MatchSoundsLike = False
.Find.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"
.Find.Replacement.Text = ""
.Find.Forward = True
.Find.Wrap = wdFindAsk
.Find.Format = False
.Find.MatchCase = False
.Find.MatchWholeWord = False
.Find.MatchWildcards = False
.Find.MatchSoundsLike = False
.Find.MatchAllWordForms = False
End With

With .Selection
.Find.Execute
.InsertColumns
.MoveLeft unit:=wdCharacter, Count:=1
.TypeText Text:="Date"
.MoveDown unit:=wdLine, Count:=1
.Paste

'Isert Office Information
.HomeKey unit:=wdStory
.Find.ClearFormatting


.Find.Text = "Office: "
.Find.Replacement.Text = ""
.Find.Forward = True
.Find.Wrap = wdFindContinue
.Find.Format = False
.Find.MatchCase = False
.Find.MatchWholeWord = False
.Find.MatchWildcards = False
.Find.MatchSoundsLike = False
.Find.MatchAllWordForms = False
End With

With .Selection
.Find.Execute
.MoveRight unit:=wdCharacter, Count:=1
.MoveRight unit:=wdWord, Count:=1
.MoveLeft unit:=wdWord, Count:=1, Extend:=wdExtend
.Copy
.HomeKey unit:=wdStory
.Find.ClearFormatting


.Find.Text = "Product Code"
.Find.Replacement.Text = ""
.Find.Forward = True
.Find.Wrap = wdFindAsk
.Find.Format = False
.Find.MatchCase = False
.Find.MatchWholeWord = False
.Find.MatchWildcards = False
.Find.MatchSoundsLike = False
.Find.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

End With

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Access XP & Word


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway