Create new text file for export

C

Cravaus

I have minimal knowledge of VBA. I have been surching google all day
yesterday to solve this problem and found no solutions that work.

I am trying to create a new FDF file to export data to a PDF form and launch
the file on a button click. I am having trouble with creating the new file.
The code I am using (and is not working) is the following:


Private Sub FDF_Click()

Dim stPDFdata As String
Dim chkName As String

'I want to check to see if the fdf file exists and if not make a new one. I
know this works for directories but it does not check for the file. Need help
here.

chkName = "C:\My File\New.fdf"

If Dir(chkName, vbDirectory) = "" Then
MkDir (chkName)
End If

StPDFdata = "<</T(lastName0)/V(" & [Last Name] & ")>>" &
<</T(FirstName0)/V(" & [First Name] & ")>>"

'I want to print the data to the fdf file. Here it says that the path does
not exist.

Open chkName For Output As #1
Print #1, stPDFdata
Close #1

'Now I want to launch my fdf file.

Application.FollowHyperlink chkName

End Sub

What do I do to get this to work?
 
R

ruralguy via AccessMonster.com

Have you single stepped the code to see what is happening?
I have minimal knowledge of VBA. I have been surching google all day
yesterday to solve this problem and found no solutions that work.

I am trying to create a new FDF file to export data to a PDF form and launch
the file on a button click. I am having trouble with creating the new file.
The code I am using (and is not working) is the following:

Private Sub FDF_Click()

Dim stPDFdata As String
Dim chkName As String

'I want to check to see if the fdf file exists and if not make a new one. I
know this works for directories but it does not check for the file. Need help
here.

chkName = "C:\My File\New.fdf"

If Dir(chkName, vbDirectory) = "" Then
MkDir (chkName)
End If

StPDFdata = "<</T(lastName0)/V(" & [Last Name] & ")>>" &
<</T(FirstName0)/V(" & [First Name] & ")>>"

'I want to print the data to the fdf file. Here it says that the path does
not exist.

Open chkName For Output As #1
Print #1, stPDFdata
Close #1

'Now I want to launch my fdf file.

Application.FollowHyperlink chkName

End Sub

What do I do to get this to work?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top