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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create new file if file does not already exist

Status
Not open for further replies.

spiral123

Programmer
Sep 9, 2002
73
CA
Function Finddoc()

Dim MySize
'' check to see if file exists
MySize = FileLen("C:\vehicle database\Ole_Docs\Comments for unit " & [Forms]![mainform]![newUnitNumber] & ".rtf")
If MySize = 0 Then
'' directory doesn't exist
DoCmd.RunMacro "worddocs"
'' run macro to create word doc from report
Else

Dim WordObj As Word.Application

' Start Microsoft Word and open the document.
Set WordObj = CreateObject("Word.Application")
WordObj.Documents.Open (Forms![mainform]![commentsfile])
WordObj.Visible = True

Const wdWindowStateMaximize = 1

Set WordObj = Nothing

End If
End Function
 
sorry i posted my code but forgot to state the problem. this code does not seem to function but im not sure why. it is supposed to run a`macro if the file does not exist otherwise it opens the specific filename in word. any help in troubleshooting is appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top