Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filename with bookmark 1

Status
Not open for further replies.

marmotje

IS-IT--Management
Dec 14, 2003
5
NL
hello,

I hope you can help me with this problem. I'am making a bookmark with acces to word with VBA. The problem is that the client want's a autonumber with this style yyyy-1000
yyyy represents the year en 1000 must be upwards with 1.

This is the code i'am using so far:
Private Sub faxsturen2_Click()
On Error GoTo Err_faxsturen2_Click

DoCmd.RunSQL "INSERT INTO faxgeschiedenis (faxnr, bedrijfsid, bedrijfinstelling, inlognaam, datumtijd, [korteomschrijving])VALUES (fax, bedrijfsid, bedrijfinstelling, FOSusername(), now(), [typ hieronder kort de inhoud van de FAX])"

Dim dbs As DAO.Database
Dim rstMergeThese As Recordset
Dim oApp As Object
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
datum = Format(Date, jjjj)


With oApp
.Documents.Open "C:\5-11-20031\faxbericht.dot"
' Move to each bookmark and insert text from the form.
.activedocument.bookmarks("bedrijfinstelling").SELECT
.selection.Text = (CStr(Forms!dhsleads!BedrijfInstelling))
.activedocument.bookmarks("TAV").SELECT
.selection.Text = (CStr(Forms!dhsleads!Lead))
.activedocument.bookmarks("faxnr").SELECT
.selection.Text = (CStr(Forms!dhsleads!Fax))
.activedocument.bookmarks("datumtijd").SELECT
.selection.Text = Now()
.activedocument.bookmarks ("datum")
.selection.tekt = datum()

'if word isn't running, start and activate it
If Err Then
Shell "C:\Program Files\Microsoft Office\Office\" & "WinWord / Automation", vbMaximizedFocus
AppActivate "Microsoft Word"
End If

End With
Exit_faxsturen2_Click:
Exit Sub

Err_faxsturen2_Click:
MsgBox "Als u een fax wilt sturen is een korte omschrijving verplicht"
Resume Exit_faxsturen2_Click

End Sub

I hope you can help me!

Best regards,

Ruud Harreman

ps. sorry for my bad english. I'am from the netherlands i hope that explain something :p ;-)
 
note: the word document must not be saved. It's a fax form and the text have to be written after the bookmarking has done. Then it must be saved with the correct file name.

thanks anyway!

best regards
R. Harreman
 
I am not getting heads and tails of your actual problem.


.ActiveDocument.SaveAs FileName:="MyWP.doc", _
FileFormat:=cnv.SaveFormat

this should do for saving in a different name

As far as autonumber is considered Chk lnk 723396
You will have to have a text field and increment the field for new record programmatically

Hope you will remember to set the object to nothing before exiting the procedure

Best of luck
 
Hi,

I hope i can explain it beter.

When the company want's to sent a letter the push the button en a word document will open. Acces write's down some information. The document must then be saved in a format (yyyy-1000) where yyyy stands voor current year and 1000 is the starting number for sending a document. so it needs to be added by 1 (don't now and can't find the right word, but every time the click it become 1001 then 1002 and so on. ) every time the click the button.

But they have to write the letter when the data is transported to word so the document must not be closed...

I'll hope you get the problem?!



best regards,
R. Harreman
 
thank you for your first reply it works fantastic.



best regards,
R. Harreman
 
Stars are not just for twinkling up in the sky

PS: I deserve one for making out your language atleast :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top