none
Some Features Of My Ribbon Addin Aren't Working In Windows Vista...Why? RRS feed

  • Question

  • I am using VB2008 to create an Ribbon Addin for Excel 2007.  The Addin is complete and the setup has been built.  I have installed the Addin on my computer and everything seems to work perfectly...I am running Windows XP Pro with Excel 2010.

    I'm trying to test this Addin on different computers.  I just installed it on a computer that is running Windows Vista with Excel 2010.  Every part of the Addin works perfectly except one.  Here is the code that seems to get hung up...it references a form that has a textbox and a save button:

        Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
            Dim userFileName As String
            Dim NwBttn As New RibbonButton
    
            userFileName = TextBox1.Text
    
            'Save Excel template
            Globals.ThisAddIn.Application.ActiveWorkbook.SaveAs("C:\Windows\Templates\Air Sheets\" & userFileName & ".xls")
    
            'Add a new button to Ribbon drop-down menu
            Globals.Ribbons.Ribbon1.AirMenu.Items.Add(NwBttn)
            NwBttn.Label = userFileName
            NwBttn.Visible = True
            NwBttn.Enabled = True
    
            Me.Close()

    The code locks up on this line and won't perform any task beyond that point...it never actually saves the file:

    Globals.ThisAddIn.Application.ActiveWorkbook.SaveAs("C:\Windows\Templates\Air Sheets\" & userFileName & ".xls")

    My Installation procedure does add a folder to the Windows directory that is labeled "Templates" and it also adds a sub folder under "Templates" that is labeled "Air Sheets".  I double checked to make sure these folders were actually added during the installation of the Addin, and they are definitely there.

    Is there a compatibility problem with Vista, or does this line of code have to be written some other way?

    Thanks

    Saturday, April 28, 2012 5:50 PM

Answers

  • sure there are, for example %APPDATA%, but of course this storage is per user, so other user logging into this computer and using your addin in outlook will not be able to see that file.
    • Marked as answer by fdegree Monday, April 30, 2012 10:06 AM
    Monday, April 30, 2012 8:14 AM
  • Thanks for the education.

    I played around with different options last night.  I found if I add the "Templates" folder, and its sub folders, as its own directory on the hard drive, it works fine on my XP system and the Vista system.  Now it's time to find a Windows 7 system and test it there.

    Are there any drawbacks to placing this folder directly on C: drive, and not having it in any other folder?

    • Marked as answer by fdegree Monday, April 30, 2012 10:06 AM
    Monday, April 30, 2012 10:06 AM

All replies

  • even if folders exists - you do not have rights to save anything inside windows folder - i guess you would have to run excel as an administrator (explicit option when right clicking excel shortcut)
    Saturday, April 28, 2012 7:08 PM
  • OK.  Instead of adding folders to the "Windows" folder during installation, is there a better place to add these folders that won't cause an administrator conflict with other computers?  I can always adjust my code to save the files to another location.

    Thanks!!!

    Saturday, April 28, 2012 9:10 PM
  • sure there are, for example %APPDATA%, but of course this storage is per user, so other user logging into this computer and using your addin in outlook will not be able to see that file.
    • Marked as answer by fdegree Monday, April 30, 2012 10:06 AM
    Monday, April 30, 2012 8:14 AM
  • Thanks for the education.

    I played around with different options last night.  I found if I add the "Templates" folder, and its sub folders, as its own directory on the hard drive, it works fine on my XP system and the Vista system.  Now it's time to find a Windows 7 system and test it there.

    Are there any drawbacks to placing this folder directly on C: drive, and not having it in any other folder?

    • Marked as answer by fdegree Monday, April 30, 2012 10:06 AM
    Monday, April 30, 2012 10:06 AM
  • by default normal users (that belong to Users group) do not have write access to C: or %programFiles% or %windows%. It is only proper to store per user data in their %home% dir or under that.
    Monday, April 30, 2012 10:33 AM
  • My ignorance is likely to show itself here...

    How would I write the "SaveAs" path if I don't know the name that the user is using to identify their personal directory?

    Globals.ThisAddIn.Application.ActiveWorkbook.SaveAs("C:\Documents and Settings\??????????\Templates\Air Sheets\" & userFileName & ".xls")

    Thanks...


    • Edited by fdegree Monday, April 30, 2012 8:31 PM
    Monday, April 30, 2012 8:30 PM
  • System.Environment.GetFolderPath

    Tuesday, May 1, 2012 7:32 PM
  • That seems to be working perfectly on my XP machine...now I need to test it on Vista and Windows 7 systems

    Thank you so much Damian...it truly helps a lot.

    Tuesday, May 1, 2012 10:42 PM