I would like to be educated on how to open an Excel Worksheet within a VSFlexGrid OR MSFlexGrid. The reason I give both as an option is because I want to explore which option is best, so if you have input on the Pros and Cons of using either and which I should use, please give it
Anyways, I know how to open one up within the VSFlexGrid. However, the reason I'm asking this Forum is because I want this VSFlexGrid to open a Worksheet according to what the other one opened previously. So let me explain:
The original Form opens a Worksheet per whatever the User wants. Meaning, he or she can open Worksheets with a certain format. Let's call this worksheet that the User theoretically opens, WorksheetRandom.xls. So the User opens up WorksheetRandom.xls and within it is an entire Workbook. However, the VSFlexGrid on my Home Form has a Worksheet called Report. The VSFlexGrid pulls from that specific Worksheet and populates the VSFlexGrid according to the specific Columns within that Worksheet. SO...what I would like to do is essentially take that same Workbook that they ALREADY CHOSE and take a different Worksheet than the original Home Form pulls and display it on a different VS or MSFlexGrid on a different form.
If I left out any information please let me know. Otherwise, if someone can tell me how to get started it would be greatly appreciated.
So I began messing around with the code and just put a very basic version of it trying to open up Excel. Here's the code, tell me if I'm missing something, again it's very basic:
Option Explicit Dim exApp As Object Dim exBook As Object Dim exSheet As Object Private Sub Form_Activate() Set exApp = CreateObject("Excel.Application") Set exBook = exApp.Workbooks.Open(strROBlitZFilePath) Set exSheet = exBook.Worksheet("Report") 'Code Goes Here :) Set exSheet = Nothing Set exBook = Nothing Set exApp = Nothing End Sub
strROBlitzFilePath is already Dim'd as a String
And assigned value as the Worksheet that the User chooses which is exactly what I'm looking for. There is an error message that pops up however. Labeled as error 1004. Attached is an image of the error. So you can take a look. If anyone can continue to help me out from here it would be greatly appreciated. I'm going to try and keep plugging away at this on my own.