Some Features Of My Ribbon Addin Aren't Working In Windows Vista...Why?
-
sábado, 28 de abril de 2012 17:50
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
Todas las respuestas
-
sábado, 28 de abril de 2012 19:08even 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)
-
sábado, 28 de abril de 2012 21:10
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!!!
-
lunes, 30 de abril de 2012 8:14
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.- Marcado como respuesta fdegree lunes, 30 de abril de 2012 10:06
-
lunes, 30 de abril de 2012 10:06
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?
- Marcado como respuesta fdegree lunes, 30 de abril de 2012 10:06
-
lunes, 30 de abril de 2012 10:33by 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.
-
lunes, 30 de abril de 2012 20:30
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...
- Editado fdegree lunes, 30 de abril de 2012 20:31
-
martes, 01 de mayo de 2012 19:32
System.Environment.GetFolderPath
-
martes, 01 de mayo de 2012 22:42
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.

