Quick Search


Tibetan singing bowl music,sound healing, remove negative energy.

528hz solfreggio music -  Attract Wealth and Abundance, Manifest Money and Increase Luck



 
Your forum announcement here!

  Free Advertising Forums | Free Advertising Board | Post Free Ads Forum | Free Advertising Forums Directory | Best Free Advertising Methods | Advertising Forums > Free Advertising Forums Directory > General Free Advertising Forums

General Free Advertising Forums This is a list of general free advertising forums. Also referred to as free classfied ad forums.

Reply
 
Thread Tools Search this Thread Display Modes
Old 03-20-2011, 07:38 PM   #1
artists266
Sergeant Major
 
Join Date: Mar 2011
Posts: 195
artists266 is on a distinguished road
Default windows 7 32bit Using VBA code to open a file stor

Another person asked me about utilizing the Attachment info style in Accessibility 2007 for any distinct process. They needed to implement it as a very simple info variety in which it would only be used to hold 1 file per record,Office 2007 Standard, and they needed to be able to open the file in an exterior software utilising a button on a form in lieu of employing the Attachment handle on the sort. Given these constraints, I was created a straightforward VBA function for doing just that:
Public Function OpenFirstAttachmentAsTempFile(ByRef rstCurrent As DAO.Recordset, ByVal strFieldName As String) As String
Dim rstChild As DAO.Recordset2
Dim fldAttach As DAO.Field2
Dim strFilePath As String
Dim strTempDir As String
strTempDir = Environ("Temp") ' Get the Temp directory from the environment variable.
If Right(strTempDir, one) <> "\" Then strTempDir = strTempDir & "\" ' Make sure the path always ends with a backslash.
Set rstChild = rstCurrent.Fields(strFieldName).Value ' the .Value to get a complex field returns the underlying recordset.
strFilePath = strTempDir & rstChild.Fields("FileName").Value ' Append the name of the first (and only) attached file to temp dir.
If Dir(strFilePath) <> "" Then ' the file already exists--delete it first.
VBA.SetAttr strFilePath,Windows 7 Home Premium Product Key, vbNormal ' remove any file attributes (e.g. read-only) that would block the kill command.
VBA.Kill strFilePath ' delete the file.
End If
Set fldAttach = rstChild.Fields("FileData") ' The binary information of the file.
fldAttach.SaveToFile strFilePath
rstChild.Close ' cleanup
VBA.Shell "Explorer.exe " & Chr(34) & strFilePath & Chr(34),windows 7 32bit, vbNormalFocus ' Use Windows Explorer to launch the file.
End Function 'OpenFirstAttachmentAsTempFile
Then I wrote this function just to test it in a database that has a Table1 with an Attachment field named "Files" in which I had already placed a file:
Public Function TestOpenFirstAttachmentAsTempFile()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Const strTable = "Table1"
Const strField = "Files" ' Attachment field in Table1
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strTable)
'rst.MoveNext ' Uncomment this line to go to the 2nd row in the Table.
OpenFirstAttachmentAsTempFile rst,Office 2010 Pro Plus Key, strField
rst.Close
End Function
By applying the VBA.Shell command with Explorer.exe,Windows 7 Starter Product Key, the file will be opened just as if you double clicked it from Windows Explorer!
See my previous blog post about attachments for more information about accessing attachments from DAO.
artists266 is offline   Reply With Quote

Sponsored Links
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 01:19 AM.

 

Powered by vBulletin Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Free Advertising Forums | Free Advertising Message Boards | Post Free Ads Forum