UtterAccess.com
Thank you for your support!       Follow UtterAccess on Twitter
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Creating Favorites    
 
   
gary84
post Feb 1 2009, 11:56 AM
Post #1

UtterAccess Veteran
Posts: 246



I've written a database to manage my Bookmarks (what Internet Explorer calls Favorites).

How do I write VBA inside Access to make the Import/Export Wizard inside IE run?

My Bookmark manager does everything I want it to do, except for that. It stores the bookmarks in a table with this structure:

CODE
Name    Type    Size

ID    Long Integer    4

Folder1    Text    255

Folder2    Text    255

Folder3    Text    255

Folder4    Text    255

Name    Text    255

URL    Memo    0


My VBA automatically creates and deletes Fields (Folder1, Folder2, etc) to accomodate whatever the worst-case tree depth is. My VBA exports the contents of my Table to a text file named "bookmark.htm" (writing THAT was a bit tricky). Is there VBA that could automatically run the Import/Export Wizard inside IE? Right now I have to do that part manually, when I need to import "bookmark.htm" into IE (which takes 3 seconds to do, so it's not a big deal... but still).

The other thing I could do is write VBA that creates hyperlinks and populates the Favorites folder directly, but I've struggled with that sort of thing before.

I used Yahoo Companion and Google Toolbar, but they got so packed with adware and junk that I couldn't stand them anymore. Also, my company does not allow the Yahoo Companion toolbar to run because it's only legal for personal use.
Go to the top of the page
 
+
Doug Steele
post Feb 2 2009, 07:57 AM
Post #2

UtterAccess VIP
Posts: 15,179
From: Don Mills, ON (Canada)



Take a look at my August, 2005 (and/or September, 2005, depending on what browse you're using) "Access Answers" column in Pinnacle Publication's "Smart Access'. You can download the columns (and sample databases) for free at Smart Access columns.
Go to the top of the page
 
+
gary84
post Feb 4 2009, 09:11 AM
Post #3

UtterAccess Veteran
Posts: 246




Thanks for the links. I did not find quite what I was looking for.

I need an example of one procedure that creates one Favorites URL bookmark.

For example, here is an example of procedure that creates one shortcut to the MDB file:

CODE
Private Sub Command427_Click()
    'Create a Desktop Shortcut to this Access MDB file
    
    'strShortcutName = "Access Shortcut"
    'strDesktop = C:\Documents and Settings\gary\Desktop
    'strProgLocn = C:\Program Files\Microsoft Office\OFFICE11\msaccess.exe
    'strDBLocn = C:\Utility Work.mdb
    'strDBPath = C:\

    Dim objWshShell As Object
    Dim objWshShortcut As Object
    
    Dim strShortcutName As String
    Dim strDesktop As String
    Dim strProgLocn As String
    Dim strDBLocn As String
    Dim strDBPath As String
    
    Dim int1 As Long
    Dim int2 As Long
    
    Set objWshShell = CreateObject("WScript.Shell")
    strShortcutName = "Access Shortcut"
    strDesktop = objWshShell.SpecialFolders("Desktop")
    strProgLocn = SysCmd(acSysCmdAccessDir) & "msaccess.exe"
    strDBLocn = CurrentDb.Name
    int1 = Len(strDBLocn)
    int2 = Len(Dir(strDBLocn))
    strDBPath = Left(strDBLocn, int1 - int2)
    
    Set objWshShortcut = objWshShell.CreateShortcut(strDesktop & "\" & strShortcutName & ".lnk")
    With objWshShortcut
        .TargetPath = strProgLocn
        .Arguments = Chr$(34) & strDBLocn & Chr$(34)
        .WorkingDirectory = strDBPath
        .WindowStyle = 4
        .Save
    End With
    Set objWshShortcut = Nothing
    Set objWshShell = Nothing
End Sub
Go to the top of the page
 
+
Doug Steele
post Feb 4 2009, 09:25 AM
Post #4

UtterAccess VIP
Posts: 15,179
From: Don Mills, ON (Canada)



Sorry, I thought you were looking to read the details of your Favorites and store them in a table.

As I believe I explained in my article, each Internet Shortcut is a separate file. All you should need to do to copy Favorites from one machine to another is copy the contents of the Favorites folder from your profile on Machine A (typically C:\Documents and Settings\UserID\Favorites) to the Favorites folder for your profile on Machine B.
Go to the top of the page
 
+
gary84
post Feb 4 2009, 07:22 PM
Post #5

UtterAccess Veteran
Posts: 246



I know how to copy them, that's not a problem.

I'm looking for the equivalent of the above to to actually create a Favorite, instead of a shortcut.
Go to the top of the page
 
+
gary84
post Feb 4 2009, 09:31 PM
Post #6

UtterAccess Veteran
Posts: 246





I found it, here it is.

CODE
Sub cmdCreate_Favorite_Click()
    CreateInternetShortCut "http://www.utteraccess.com/", "C:\Documents and Settings\" & UserNameWindows & "\Favorites\UtterAccess.url"
    
    ' http://www.utteraccess.com/forums/printthread.php?Cat=&Board=47&main=1674600&type=thread
End Sub

Function UserNameWindows()
    Dim sUserNameWindows
    sUserNameWindows = Environ("USERNAME")
    UserNameWindows = sUserNameWindows
End Function

Sub CreateInternetShortCut(TargetURL As String, FullPath As String)
    Dim iFile As Integer
    iFile = FreeFile
    Open FullPath For Output As #iFile
    Print #iFile, "[InternetShortcut]"
    Print #iFile, "URL=" & TargetURL
    Close #iFile
End Sub
Go to the top of the page
 
+
Doug Steele
post Feb 5 2009, 06:30 AM
Post #7

UtterAccess VIP
Posts: 15,179
From: Don Mills, ON (Canada)



That's certainly one approach, although I'd use Retrieving a Special Folder's location as "The Access Web" to determine where the user's Favorites folder is located rather than assuming it's under C:\Documents and Settings\ (mine aren't, for instance, since I used TweakUI to move many things like that to my D drive to make OS upgrades safer). As well, I usually use the WritePrivateProfileString APi function when working with INI files.

You might also check what Randy Birch has at DoAddToFavDlg: Add and Manipulate IE Favourite Links (The GetFolderPath he uses is essentially the same code as at the site cited above)

Obligatory warning: Randy's site is aimed at VB programmers. There are some significant differences between the controls available for forms in VB and in Access, so that some of his samples don't port directly to Access. Doing a quick look at this sample, the only thing that jumped out at me is that in VB you refer to the contents of a text box through its .Text property, whereas in Access you'd use its .Value property.
Go to the top of the page
 
+
gary84
post Feb 5 2009, 07:34 PM
Post #8

UtterAccess Veteran
Posts: 246



Hey that's a great idea. I incorporated that.

Attachment shows what I was intending to do. This gives me seamless import/export between my IE favorites and a Table, also between my the bookmark.htm file and a Table.

It automatically creates as many Folder Fields as needed when you Import.

I think I got all the bugs out but we'll see.
Attached File(s)
Attached File  Bookmarks Import-Export 2009-02-05-0.zip ( 284.77K ) Number of downloads: 9
 
Go to the top of the page
 
+

Reply to this topicStart new topic

 



RSS Go to Top  ·  Lo-Fi Version Time is now: 16th May 2012 - 07:26 PM