To put things into perspective, I've been using Visual Studio for a total of
1 week now. I'm researching how to transports data from Filemaker to MySQL
and found an interesting article on how to accomplish this. I just can't
interpret the instructions into tasks that I can do. In the article, the
author says....
I do a daily automated export from a filemaker application to MS Access and
I have done it in the past to mysql as well. I am also 90%
done writing a VB.net app that does similiar stuff. It is pretty easy do
because FileMaker exposes itself to Windows via a COM object. So
basically in either VBA or VB.net/VB6/C++ you just add the FileMaker COM
object as a reference and then create an instance of the FileMaker
Application object and Filemaker document object. Look at the sample code I
have posted below.
Now I've figured ou tpart of it. I created a new project (blank) and have
added the Filemaker COM reference (what ever that is). So now I can see the
FMPRO50LIB under reference which is under my project name "FMInterface". How
do I create an instance of the application and document objects?
The sample code he provided is below....
********* Sample Code ***********
********* This is provided as is with no guarentee ********
Function ControlFileMaker()
'On Error GoTo errorhandler
Dim cnn1 As ADODB.Connection
Dim rstFileMakerImportLog As ADODB.Recordset
Dim strCnn As String
Dim dtStartTime As Date
Dim dtEndTime As Date
Dim ExportCompleted As Boolean
Dim ErrorMessage As String
Dim strSQL As String
Dim appFM As FMPRO50Lib.Application
Set appFM = New FMPRO50Lib.Application
Dim FMdocs As FMPRO50Lib.Documents
Set FMdocs = appFM.Documents
Dim fmCinApps As FMPRO50Lib.Document
appFM.Visible = False
' Open a connection to Import Log table.
dtStartTime = Time
'Connects to my FileMaker database
Set fmCinApps = FMdocs.Open("C:<somefilename>.fp5", <password>)
'calls the "jason export" script in the <somefilename>.fp5 file
'that exports all records based on my find set as a .dbf then it opens
fmCinApps.DoFMScript ("jason export")
'the following do loop is used to prevent MSAccess from going to the
rest
'of the code until
'FileMaker is done exporting its data
Do Until IsEmpty(FMdocs.Active)
Loop
'I have set up a log table in my access program and the following
Do.cmd.runsql writes the date, start time and end time of the import.
'If the import
'fails then the errorhandler will run a different SQL statement that
'will list the date, starttime and error message.
strSQL = "INSERT INTO tblFileMakerImportLog ( RunDate, StartTime,
EndTime, Completed ) values ('" & Date & "', '" & dtStartTime & "', '"
&
Time() & "', true);"
Debug.Print strSQL
'Stops Access from popping up any warning messages about appending
'data to my log table
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
'I can not remember why I commented out the next command. It is
suppose to run the sub routine that cloose filemaker. There must have
been some bug in my code that
'I never corrected.
'CloseFileMaker
Exit Function
errorhandler:
strSQL = "INSERT INTO tblFileMakerImportLog ( RunDate, StartTime,
EndTime, Completed, note ) values ('" & Date & "', '" & dtStartTime &
"', '" & Time() & "', true,'" & Err.Description & ");"
Debug.Print strSQL
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
CloseFileMaker
End Function
Sub CloseFileMaker()
Dim appFM As FMPRO50Lib.Application
Set appFM = New FMPRO50Lib.Application
Dim FMdocs As FMPRO50Lib.Documents
Set FMdocs = appFM.Documents
Dim fmCinApps As FMPRO50Lib.Document
appFM.Visible = True
appFM.Quit
End Sub
Carlos J. Quintero [VB MVP] - 29 May 2006 09:36 GMT
Hi,
For VB.NET programming questions, it is better to use the newsgroup
microsoft.public.dotnet.languages.vb. This newsgroup is really about VS.NET,
the IDE.
That said, you can create COM objects in VB.NET in two ways:
- If you have added a reference, you can use early binding:
Dim obj As MyCOMTypeLibrary.MyClass
obj = New MyCOMTypeLibrary.MyClass()
- If not, the equivalent late binding of the CreateObject function of VB6 in
VB.NET is:
Dim objType As System.Type
Dim obj As Object
objType = System.Type.GetTypeFromProgId("MyCOMTypeLibrary.MyClass")
obj = System.Activator.CreateInstance(objType)
Your post and your sample is too long to look into and you don´t say the
specific error that you get, but the above should help.

Signature
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
> To put things into perspective, I've been using Visual Studio for a total
> of 1 week now. I'm researching how to transports data from Filemaker to
[quoted text clipped - 112 lines]
>
> End Sub