Page 1 of 2 12 LastLast
Results 1 to 40 of 58

Thread: open xls file from OpenFileDialog

  1. #1

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    open xls file from OpenFileDialog

    hi
    i have been browsing your forum and it is very informative.
    i have been using vba and would like to advance to vb.
    i have d/l the 2005 express edition and can feel my way around a little.

    i have made a estimating program in vba and would like to link to vb as mauch as possible.

    I have made a form with a OpenFileDialog control, it opens the browser but i need some more code to actually open the xls workbook.

    how many "i" can i have??

    any help much appreciated

    Also the tutorials helped me actually open a xls file but not thru the OpenFileDialog
    thx heaps
    toe

  2. #2
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: open xls file from OpenFileDialog

    Welcome to the forums.

    I am not sure I understand what you mean by 'how many "i" can i have??', but I can try to help with the rest.

    A common misconception is that the OpenFileDialog and SaveFileDialog will actually open and save the files for you. While they do have methods for opening text only files, their main function is to show the dialog to the user and return the path the user picks.

    If you already know how open an XLS file, then all you need to do is show the OpenFileDialog. After that just open the XLS file located at the OpenFileDialog.FileName poperty.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  3. #3

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    thx for the reply

    i meant how many "i's" can one have in a post

    My problem is i dont no how to open the file from the OpenFileDialog

    cheers
    toe

  4. #4
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: open xls file from OpenFileDialog

    A simple search in the Visual Studio help files or online would have told you the answer to that question.

    http://msdn2.microsoft.com/en-us/lib...og(VS.80).aspx
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: open xls file from OpenFileDialog

    as eyermonkey mentioned, the openfiledialog doesn't actually open a file. What it does, is present a common user interface for a user to select a file to open. The OpenFileDialog basically is just a class that shows the file open dialog that is common to windows, and returns what file was selected to be opened via a property (specifically the FileName or FileNames property)

    that is all the openfiledialog does. after it has done its job, it is the programmers job to do whatever needs to be done with the file, which is currently only represented in your program as a string like "C:\files\myfile.xls".

    So the next question would be what is it you want to do with the excel file? if you just want to open it as in open it in excel, then you could use the process.start() method to launch the xls file like you were double clicking it in windows...

    or if you want to open the xls file because you want to modify or work with data contained in it, you will need to search on automating excel, which there are many posts about on the forum.

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,448

    Re: open xls file from OpenFileDialog

    You don't open a file from the OpenFileDialog. eyeRMonkey said in his first post that the OFD is just a visual way for the user to select a path, which is then returned through the FileName property. You said that you already know how to open an XLS file so you simply plug that path into what you already have.

    There are two main ways to use an OFD in 2005. If you want to reuse the same dialogue over and over then you're best to add it to your form at design time and set all the properties there. You would then use it like this:
    VB Code:
    1. If Me.OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
    2.     MessageBox.Show("You selected " & Me.OpenFileDialog1.FileName)
    3. End If
    If you want to create a dialogue on demand then you would do it like this:
    VB Code:
    1. Using ofd As New OpenFileDialog
    2.     'Set desired properties here.
    3.  
    4.     If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
    5.         MessageBox.Show("You selected " & ofd.FileName)
    6.     End If
    7. End Using
    The Using block ensures that the dialogue is disposed afterwards.

  7. #7
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: open xls file from OpenFileDialog

    Wow. I never new about the Using block. Thanks JMC.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  8. #8

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    thx for the replies guys.

    mmm. why would they have a function that shows the browser then not be able to open the selected file from ther!!!

    Bit like havin a car door that dont open.

    ill work on it til i work it out.
    thx
    toe

  9. #9
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,448

    Re: open xls file from OpenFileDialog

    Quote Originally Posted by toecutter
    why would they have a function that shows the browser then not be able to open the selected file from ther!!!
    Think about what you're saying. How many different file types can there be on a computer? It's unlimited. "Opening" a file means something different for every single one of them. If you want to behave as though the file was double-clicked in Windows Explorer then just pass the path to Process.Start. That may not be what you want though. You might want to handle the file in any number of different ways, so the OFD tells you what file the user selected and then you do what you want with it. You can't expect the system to do everything for you. Otherwise we'd be out of a job.

  10. #10
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: open xls file from OpenFileDialog

    Quote Originally Posted by toecutter
    why would they have a function that shows the browser then not be able to open the selected file from ther!!!
    No, it does exactly what its name says: it shows a dialog for opening a file. It does not open the file. There a million different ways to open a file and handle the data inside them, how would the dialog know which one you wanted?
    Last edited by eyeRmonkey; Apr 14th, 2006 at 12:12 AM.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  11. #11
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,448

    Re: open xls file from OpenFileDialog

    Quote Originally Posted by eyeRmonkey
    Wow. I never new about the Using block. Thanks JMC.
    Note that Using accepts types that implement IDisposable only. It is designed so that you can use this:
    VB Code:
    1. Using myObject As New MyDisposableType
    2.     'Use myObject here.
    3. End Using
    instead of this:
    VB Code:
    1. Dim myObject As New MyDisposableType
    2.  
    3. Try
    4.     'Use myObject here.
    5. Finally
    6.     myObject.Dispose()
    7. End Try

  12. #12

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    hi
    found this code but it has a error in it that iam unable to sort out>

    Code:
      Private Sub bthOpenProject_Click(ByVal sender As System.Object, _
       ByVal e As System.EventArgs) Handles bthOpenProject.Click
            ' Displays an OpenFileDialog so the user can select a Cursor.
            Dim openFileDialog1 As New OpenFileDialog()
            openFileDialog1.Filter = "Cursor Files|*.cur"
            openFileDialog1.Title = "Select a Cursor File"
    
            ' Show the Dialog.
            ' If the user clicked OK in the dialog and 
            ' a .CUR file was selected, open it.
            If openFileDialog1.ShowDialog() = DialogResult.OK Then
                ' Assign the cursor in the Stream to the Form's Cursor property.
                Me.Cursor = New Cursor(openFileDialog1.OpenFile())
            End If
        End Sub
    the part with the error is this>
    Code:
    DialogResult.OK
    it has a green squigly line and a small brown rectangle under "K"
    cheers
    toe
    Last edited by toecutter; Oct 31st, 2007 at 07:13 AM.

  13. #13
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,448

    Re: open xls file from OpenFileDialog

    Use your IDE. It tells you exactly how to fix the problem. Mouse over the line in error and a little error icon will popup. Mouse over that and a drop-down arrow appears. Click that and a dialogue opens that gives you tips on how to fix the error. In this case it tells you to do exactly what I posted in post #6.

    If you had typed the code yourself rather than pasting it Intellisense would have given you the correct code in the first place. It was Intellisense that gave the dud code in previous versions because that issue of access Shared members through instances was not flagged as a problem but simply ignored. That's why many code examples using ShowDialog that were written in VB.NET 2003 will give that warning when used in VB 2005.

  14. #14
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,448

    Re: open xls file from OpenFileDialog

    Also, that example won't help you too much with an XLS file in most situations. OpenFile returns a read-only Stream object. I doubt that that will help you with a Excel spreadsheet, which you would presumably want to open in a new Excel process or in an Excel application that you control through Office automation.

  15. #15

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    ok thx
    ill spend a bit of time with it.
    that post re: Use your IDE.
    was very helpful thx
    toe
    Last edited by toecutter; Apr 14th, 2006 at 02:23 AM. Reason: spelling

  16. #16

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    ok
    it looks like it is to hard to open a excel workbook using the OpenFileDialog control.

    Maybe i need some code that will browse to a specific folder then select a excel workbook form that folder??

    any ideas??
    cheers
    toe

  17. #17

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    or maybe this
    Code:
    Private Sub btnOpenProject_Click(ByVal sender As System.Object, _
     ByVal e As System.EventArgs) Handles btnOpenProject.Click
    
            With ThisApplication.FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogOpen)
                .AllowMultiSelect = True
                .Filters.Clear()
                .Filters.Add("Excel Files", "*.xls;*.xlw")
                .Filters.Add("All Files", "*.*")
                If .Show Then
                    .Execute()
                End If
            End With
        End Sub
    but i need to declare "ThisApplication"

    can any one help with this???
    cheers
    toe

  18. #18
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,448

    Re: open xls file from OpenFileDialog

    Alright, you need to qualify exactly what it is you are trying to do. Now it looks like you actually want to open a dialog within the Excel application. That isn't the same thing as opening a .NET OpenFileDialog. Which do you want to do? Then we'll know what advice to give.

  19. #19

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    sry for the confusion..
    i wont to browse for a excel file in a specific folder, open it then edit save and close from excel
    cheers
    toe

  20. #20
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: open xls file from OpenFileDialog

    Did you add a reference to Excel? Then you also need to add the imports microsoft.Office.Interop to the top of your class. Then define a object variable of Excel.Application type to avoid any confusion with VB's Application object.
    VB Code:
    1. Option Explicit On
    2.  
    3. Imports Microsoft.Office.Interop 'If you dont have .Interop then you need to install the PIAs (see link in my sig)
    4. 'You can also use the .Core class but its not as flexible
    5.  
    6. Private moApp As Excel.Application
    7.  
    8. Private Sub btnOpenProject_Click(ByVal sender As System.Object, _
    9.  ByVal e As System.EventArgs) Handles btnOpenProject.Click
    10.  
    11.     moApp = CreateObject("Excel.Application")
    12.  
    13.     With moApp.FileDialog(MsoFileDialogType.msoFileDialogOpen)
    14.         .AllowMultiSelect = True
    15.         .Filters.Clear()
    16.         .Filters.Add("Excel Files", "*.xls;*.xlw")
    17.         .Filters.Add("All Files", "*.*")
    18.         If .Show = DialogResult.OK Then
    19.             moApp.Workbooks.Open(.FileName)
    20.         End If
    21.     End With
    22. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  21. #21

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    hi
    yes i ref the excel exe and installed the PIA's. i dont have the microsoft.Office.Interop .
    do i have to ref the PIA's?
    toe
    Last edited by toecutter; Apr 14th, 2006 at 08:47 PM. Reason: spelling

  22. #22

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    hi
    which file do i actually upload as a att?

    i have posted a link to a screen shot
    which shows 2 errors.
    can anyone help me with these pls??

    http://members.iinet.net.au/~mcapper...en%20shot..JPG

    i have almost got it
    it will not build which i think is because of the errors.

    cheers
    toe

  23. #23

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    bump

  24. #24

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    i am currently running excel 2002...do u think they may be a problem
    cheers
    toe

  25. #25
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: open xls file from OpenFileDialog

    This should work for you but since you want multiple file selections then you are going to need to also loop through to open each one.
    Looks like you may also have a reference issue with the exclamation error?

    VB Code:
    1. Private Sub btnOpenProject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    2.  
    3.         moApp = CreateObject("Excel.Application")
    4.  
    5.         With moApp.FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogOpen)
    6.             .AllowMultiSelect = True
    7.             .Filters.Clear()
    8.             .Filters.Add("Excel Files", "*.xls;*.xlw")
    9.             .Filters.Add("All Files", "*.*")
    10.             If .Show = DialogResult.OK Then
    11.                 moApp.Workbooks.Open(.SelectedItems.Item(0).ToString)
    12.             End If
    13.         End With
    14.     End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  26. #26

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    thx ..but carnt get it to work...
    i tried to install the pia's in your sig but it says to insatll office 2003 first.
    I only have xp office!!!
    cheers
    toe

  27. #27
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: open xls file from OpenFileDialog

    Office XP and 2003 contain the PIAs so either one will work. Try removing the references and readding them.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  28. #28

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    thx

    yer removed then added agin but i still get the squiggly line under this part
    Microsoft.Office.Core.MsoFileDialogType

    says it is ambiguous??

    and it also wonts me to change this
    DialogResult.OK
    to
    System.Windows.Forms.DialogResult.OK

    thx heaps
    toe

  29. #29
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: open xls file from OpenFileDialog

    Must be something with 05 as in 03 its fine.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  30. #30

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    bugger

    one other question

    i had this referenced before and it seemed to have helped some other code
    VBIDE
    now i carnt find where i got it from??
    any ideas
    toe

  31. #31
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: open xls file from OpenFileDialog

    Only thing I can think of is if you upgraded a VB 6 project?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  32. #32

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    mmmm
    dont have vb6 but i have visual studio.net 2003 also installed

    maybe i should remove that??
    toe

  33. #33
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: open xls file from OpenFileDialog

    No, I was meaning if you had previously written the project in vb6 and converted it to 05.

    No need to remove 2003.

    What does the actual error message state?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  34. #34

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    hi

    the failed to build error is

    "Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated."

    screen shot
    http://members.iinet.net.au/~mcapper/ss2.JPG

    cheers
    toe

  35. #35
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: open xls file from OpenFileDialog

    Its probably because your importing both the .Core and the .Interop. Why are you importing VBA? I really dont think you need it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  36. #36

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    Quote Originally Posted by RobDog888
    Its probably because your importing both the .Core and the .Interop. Why are you importing VBA? I really dont think you need it.
    thx
    i commented out the core but still no luck..
    i still get the squiggly line under this part
    "Microsoft.Office.Core.MsoFileDialogType."
    Stating it is mbiguous in the microsoft office core
    since i got rid of the core should i change the above text???

    VBA is there cause i got no idea

    cheers
    toe
    Last edited by toecutter; Apr 17th, 2006 at 04:07 PM.

  37. #37
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: open xls file from OpenFileDialog

    Take VBA reference out.

    The only thing left I can think of is that if your running the Express version of 05 as it states it doesnt have support for Office but that really shouldnt be the issue here. But then again, it works for me but I have VSTO 2003 installed into VS 2003.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  38. #38

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    Quote Originally Posted by RobDog888
    Take VBA reference out.

    The only thing left I can think of is that if your running the Express version of 05 as it states it doesnt have support for Office but that really shouldnt be the issue here. But then again, it works for me but I have VSTO 2003 installed into VS 2003.

    mmm..k
    any links/contacts on who i could approach re this?

    thx for your help
    toe

  39. #39

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,141

    Re: open xls file from OpenFileDialog

    looks like visual studio express edtion dosnt support office developement support

    http://msdn.microsoft.com/vstudio/products/compare/

    I may have to get Visual Studio Tools For Office??

    cheers
    toe

  40. #40
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: open xls file from OpenFileDialog

    VB Express 2005 does not support VSTO either. This is part of the reason its free. In order to do any in depth programming you need the Pro version or above.

    All that means is that you wont get the integrated features and utilities and help files. You should still be able to develop something but I havent installed 05 yet so I cant test it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width