473,395 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

code to create/modify word document from access

2
I have created the following code the first part works to create a word document with but when I have created the document and existed word, I then click the button again to open up the document to edit it, it opens the document but as a new one again. Fairly new to this so any help would be appreciated.

Private Sub Command132_Click()
DoCmd.Save

Dim LWordDoc As String
Dim oApp As Object
Dim strFilename As String
Dim strFilename1 As String


'Path to the word document
' LWordDoc = "c:\building_control\export\" & strFilename1 & "_" & strFilename
LWordDoc = "c:\building_control\export\" & strFilename1 & "_" & strFilename & ".doc"

strFilename = Me.inspection
strFilename1 = Me.job



If Dir(LWordDoc) = "" Then


Set oApp = CreateObject("Word.Application")
oApp.Visible = True
oApp.Documents.Add

oApp.WindowState = wdWindowStateMaximize '
oApp.ActiveDocument.SaveAs FileName:="c:\building_control\export\" & strFilename1 & "_" & strFilename

'Forms!inspection_details!word_document = Forms!inspection_details!job & "_" & Forms!inspection_details!inspection & ".doc" ''



Else


'Open the Document
application.FollowHyperlink "c:\building_control\export\" & strFilename1 & "_" & strFilename & ".doc"


End If

End Sub
Sep 24 '06 #1
0 2819

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jon Paal | last post by:
any way to modify text content of a word document through ASP ?
3
by: di | last post by:
I have a Access Database, and I would like to create a word document that (preferable would filter)links to ACCESS table or query. I would like to print the word document on the filtered record...
0
by: daveh | last post by:
Can anyone help with the following incompatibility problem between office 2k and office xp? The code below works OK in Access 2k. But on a PC with office XP, it fails at the "Set appword . . ....
0
by: Linda Cacina | last post by:
Hello all you fine folks, Here is some code I am using to merge data from a single record Access 2K3 table into a NEW word document based on a pre-defined Word merge template doc. All I want to...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
9
by: Hayato Iriumi | last post by:
Hello, I hear some hypes about creating code to generate C# or VB .NET code, that is, code generation (sounds straight forward enough). I haven't really seen how it's done in real world. I'm...
1
by: qasimraza1979 | last post by:
HI, I am currently analysing the scenario to modify word document if MS word in not installed on the server. Actually I was thinking to modify my word document using...
1
by: webgirl | last post by:
Hi everyone, I have a weird problem with some Word/Excel automation code that I run from Access (not sure if I should therefore post this in the Access forum..? Thought I'd try here first) ...
1
by: kayberrie | last post by:
I want to write a VBA mail merge code. I want to link the code/macro/dohicky to a nifty little button so it makes life easy. I think I can handle the button part, the code part - not so much. I know...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.