Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / March 2006

Tip: Looking for answers? Try searching our database.

Open InfoPath from Access

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
chrismahoney@gmail.com - 21 Mar 2006 02:51 GMT
Hi

I'm moving an old Outlook form across to InfoPath, and I'm trying to
figure out how to open the form from Access. This is the current code:

Dim objOutlook As Outlook.Application
Dim nsOutlook As Outlook.NameSpace
Dim folTask As Object
Dim tskPhoto As Outlook.MailItem

Set objOutlook = New Outlook.Application
Set nsOutlook = objOutlook.GetNamespace("MAPI")
Set folTask = nsOutlook.GetDefaultFolder(olFolderInbox)
Set tskPhoto = folTask.Items.Add("IPM.Note.library Photos")

With tskPhoto
   .UserProperties.Item("FilmNumber").Value = filmNumber
   .UserProperties.Item("StaffNumber").Value = StaffNumber
   .Subject = "Please enter the relevant information for each photo in
the 'Photos' form"
   .Body = " "
   .ReminderSet = True
   .ReminderTime = DateAdd("d", 6, Date) & " 12:00:00"
End With
Call tskPhoto.Recipients.Add(StaffName)
Call tskPhoto.Send

I didn't write this code, but it appears to be passing two variables
(FilmNumber and StaffNumber) into the Outlook form. I've created a
couple of fields in InfoPath for these variables to go into, but I have
no idea how to modify the above code to use InfoPath instead of
Outlook.

Help please :)

Thanks
Chris
chrismahoney@gmail.com - 21 Mar 2006 04:27 GMT
I've tried a few things, and so far I have this:

Dim objInfoPath As New InfoPath.Application
objInfoPath.XDocuments.Open Application.CurrentProject.Path &
"\LibraryPhotos.xsn"
objInfoPath.XDocuments(0).DOM.selectSingleNode("//my:FilmNumber").Text
= filmNumber

Am I on the right track? That code fails on the .Open line, with the
following message:

Run-time error '-2147209207 (80043009)':
InfoPath cannot open the following file: LibraryPhotos.xsn.
The file is not a valid XML file.
??
The form contains XML that cannot be parsed:
An invalid character was found in text content.
Line 1. Position 5

I've taken a look at line 1 pos 5 but it appears blank (like a space)
in Notepad. I suppose it could be a hidden character though, as after
all it's a binary file (first 4 bytes are "MSCF", as you'd expect from
a Microsoft Cabinet File). I thought maybe I need to decompress the XSN
first, but that didn't help. I do get a slightly different message
though:

Run-time error '-2147209148 (80043044)':
InfoPath cannot open the following file: manifest.xsf.
The file does not appear to be an InfoPath form.
??
The processing instruction in the file is missing or invalid.

I've also tried opening the template.xml file, but I get an
"Insufficient Security Privilege" message.

Presumably it's my code that's wrong, rather than the XSN/XSF/XML
files. Can anyone give me any pointers?

Thanks
Chris
chrismahoney@gmail.com - 21 Mar 2006 05:22 GMT
Success... sort of.

The following code works:

Dim objInfoPath As New InfoPath.Application
objInfoPath.XDocuments.NewFromSolution
"\\Jupiter\ChrisMa\Settings\Desktop\LibraryPhotos.xsn"
objInfoPath.XDocuments(0).DOM.selectSingleNode("//my:FilmNumber").Text
= filmNumber

Of course, I don't want an absolute path in there, so I changed the
second line to:

objInfoPath.XDocuments.NewFromSolution Application.CurrentProject.Path
& "\LibraryPhotos.xsn"

Unfortunately, this fails.

Run-time error '-2147209000 (800430d8)':
InfoPath cannot create a new, blank form.
InfoPath cannot open the form. To fix this problem, contact your
system administrator.
??
Form template: D:\Databases\Library\LibraryPhotos.xsn
The selected file is an update of a form on your computer. However,
the update has been blocked because the author of the file cannot be

The message just stops there, the end of it has been cut off. Any ideas
what it's trying to say, or how to get around it?

Thanks
Chris
renee rieser - 21 Mar 2006 20:06 GMT
Chris,

I'm just taking a stab here, but with the infopath form in design
mode,  go to tools/form options/security and uncheck the "auto
determine security" checkbox and change it to "Domain" security.

Republish the infopath form and then try again.

Renee

>InfoPath cannot create a new, blank form
chrismahoney@gmail.com - 21 Mar 2006 21:08 GMT
That did it! Thanks! :)
Chris - 21 Mar 2006 23:03 GMT
I've run into another problem now. I have the following code in Access:

Dim objInfoPath As New InfoPath.Application
objInfoPath.XDocuments.NewFromSolution Application.CurrentProject.Path
& "\LibraryPhotos.xsn"
objInfoPath.XDocuments(0).DOM.selectSingleNode("//my:FilmNumber").Text
= filmNumber

And the following in InfoPath:

Sub msoxd_my_FilmNumber_OnAfterChange(eventObj)
   If eventObj.IsUndoRedo Then
       Exit Sub
   End If
   Dim MainAdapter
   Dim FilmNumber
   Set MainAdapter = XDocument.DataAdapters("Main connection")
   FilmNumber = XDocument.DOM.selectSingleNode("//my:FilmNumber").text
   MainAdapter.Command = "SELECT * FROM tblPHOTO_CATALOG WHERE
PHO_film_number = '" & FilmNumber & "' ORDER BY PHO_photo_number;"
   MainAdapter.Query
End Sub

Independently, they work fine. The Access code correctly opens the
database and puts the filmNumber variable into the my:FilmNumber text
box. The InfoPath code correctly requeries whenever you change the film
number.

The problem occurs when both subs are present. When running the code in
Access, InfoPath pops up and displays the form for a split-second, then
the my:FilmNumber box updates and BAM! My repeating section disappears.
I can't understand why this is happening, because as I said above, the
two sections of code work perfectly on their own.

As for the form itself, I have one big repeating section containing
everything except for the my:FilmNumber box. I've tried putting
my:FilmNumber inside the repeating section, but there is no difference.
I've also tried pulling other controls out of the repeating section,
that doesn't help either (they still disappear).

Any ideas?

Thanks
Chris
Chris - 23 Mar 2006 21:47 GMT
I haven't changed anything, but it's working now. I'm so confused.

I wonder if maybe it has something to do with the conflict I got a few
minutes ago, see my new topic "Form Conflict" for the details.

Chris
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.