ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Importing Access to Excel (https://www.excelbanter.com/excel-programming/403776-importing-access-excel.html)

Stumped Programmer

Importing Access to Excel
 
I am wondering how to use excel's automated reference to automate updating
data in a excel file using access.

Ex: Using the ".Range("G9").Value ="

I have personally tried using this code (it did not work)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

With objExcel
.Visible = True
.Workbooks.Open("\EDV SUMMARY SAMPLE.xls")
*.Range("G9").Value = Val(EDV_DMM_STD_SummaryDataGridView(3,1))*
.Range("A1").ColumnWidth = 20
.Range("A1").Font.Bold = True
.Range("A2").Value = "So. Main St."
.Range("A3").Value = "Hartford" & ", " & "CT"
End With

**this is a control table conected to a linked databse. I am trying
to point to a cell in the table by using indexes and write the data to the
excel doc.


Roger Govier[_3_]

Importing Access to Excel
 
Hi

I think you would need a

..Sheets("Sheet1").Activate or .Select
before referring to the individual cell ranges.

--

Regards
Roger Govier

"Stumped Programmer" <Stumped wrote in
message ...
I am wondering how to use excel's automated reference to automate updating
data in a excel file using access.

Ex: Using the ".Range("G9").Value ="

I have personally tried using this code (it did not work)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

With objExcel
.Visible = True
.Workbooks.Open("\EDV SUMMARY SAMPLE.xls")
*.Range("G9").Value =
Val(EDV_DMM_STD_SummaryDataGridView(3,1))*
.Range("A1").ColumnWidth = 20
.Range("A1").Font.Bold = True
.Range("A2").Value = "So. Main St."
.Range("A3").Value = "Hartford" & ", " & "CT"
End With

**this is a control table conected to a linked databse. I am trying
to point to a cell in the table by using indexes and write the data to the
excel doc.


Stumped Programmer[_2_]

Importing Access to Excel
 
Thank you,

The cells I am refering to are in a Datagrid (stated "table" in post) in my
project.
With the line: *.Range("G9").Value =
Val(EDV_DMM_STD_SummaryDataGridView(3,1))* I am trying to take the value
(text or integer) of cell (3,1) in the Datagrid and transfers it to cell "G9"
in Excel


"Roger Govier" wrote:

Hi

I think you would need a

.Sheets("Sheet1").Activate or .Select
before referring to the individual cell ranges.

--

Regards
Roger Govier

"Stumped Programmer" <Stumped wrote in
message ...
I am wondering how to use excel's automated reference to automate updating
data in a excel file using access.

Ex: Using the ".Range("G9").Value ="

I have personally tried using this code (it did not work)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

With objExcel
.Visible = True
.Workbooks.Open("\EDV SUMMARY SAMPLE.xls")
*.Range("G9").Value =
Val(EDV_DMM_STD_SummaryDataGridView(3,1))*
.Range("A1").ColumnWidth = 20
.Range("A1").Font.Bold = True
.Range("A2").Value = "So. Main St."
.Range("A3").Value = "Hartford" & ", " & "CT"
End With

**this is a control table conected to a linked databse. I am trying
to point to a cell in the table by using indexes and write the data to the
excel doc.


George Nicholson

Importing Access to Excel
 
I am trying to take the value
(text or integer) of cell (3,1) in the Datagrid and transfers it to cell
"G9"


Yes, but "G9" on WHAT SHEET?

*Assuming* objExcel is properly declared as Excel.Application somewhere
else(since it isn't declared in the supplied snippet) then:

objExcel.Range("G9").Value = yada yada

is the same as

Application.Range("G9").Value = yada yada

That simply doesn't tell Excel what your intentions are.

I'm guessing you are getting a 1004 error which usually translates as "You
haven't given me enough information. I don't know what (or which) object
you're trying to reference. Please be specific."

Again, that's an assumption. You say "it did not work", which is, again, a
little light on information. (it threw an error?, did nothing?, did
something other than intended?, crashed? etc.)


--
HTH,
George


"Stumped Programmer" wrote in
message ...
Thank you,

The cells I am refering to are in a Datagrid (stated "table" in post) in
my
project.
With the line: *.Range("G9").Value =
Val(EDV_DMM_STD_SummaryDataGridView(3,1))* I am trying to take the value
(text or integer) of cell (3,1) in the Datagrid and transfers it to cell
"G9"
in Excel


"Roger Govier" wrote:

Hi

I think you would need a

.Sheets("Sheet1").Activate or .Select
before referring to the individual cell ranges.

--

Regards
Roger Govier

"Stumped Programmer" <Stumped wrote
in
message ...
I am wondering how to use excel's automated reference to automate
updating
data in a excel file using access.

Ex: Using the ".Range("G9").Value ="

I have personally tried using this code (it did not work)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

With objExcel
.Visible = True
.Workbooks.Open("\EDV SUMMARY SAMPLE.xls")
*.Range("G9").Value =
Val(EDV_DMM_STD_SummaryDataGridView(3,1))*
.Range("A1").ColumnWidth = 20
.Range("A1").Font.Bold = True
.Range("A2").Value = "So. Main St."
.Range("A3").Value = "Hartford" & ", " & "CT"
End With

**this is a control table conected to a linked databse. I am
trying
to point to a cell in the table by using indexes and write the data to
the
excel doc.




Stumped Programmer[_2_]

Importing Access to Excel
 
I am sorry if my info was to little. The only line in my code that does not
work is the:
Range("G9").Value = Val(EDV_DMM_STD_SummaryDataGridView(3,1)). I am
getting a this error when I run my application (and press the button):
Argument 'Expression' cannot be converted to type 'DataGridViewTextBoxCell'.
Also objExcel is declared in my module, which of course I did not post.

"George Nicholson" wrote:

I am trying to take the value
(text or integer) of cell (3,1) in the Datagrid and transfers it to cell
"G9"


Yes, but "G9" on WHAT SHEET?

*Assuming* objExcel is properly declared as Excel.Application somewhere
else(since it isn't declared in the supplied snippet) then:

objExcel.Range("G9").Value = yada yada

is the same as

Application.Range("G9").Value = yada yada

That simply doesn't tell Excel what your intentions are.

I'm guessing you are getting a 1004 error which usually translates as "You
haven't given me enough information. I don't know what (or which) object
you're trying to reference. Please be specific."

Again, that's an assumption. You say "it did not work", which is, again, a
little light on information. (it threw an error?, did nothing?, did
something other than intended?, crashed? etc.)


--
HTH,
George


"Stumped Programmer" wrote in
message ...
Thank you,

The cells I am refering to are in a Datagrid (stated "table" in post) in
my
project.
With the line: *.Range("G9").Value =
Val(EDV_DMM_STD_SummaryDataGridView(3,1))* I am trying to take the value
(text or integer) of cell (3,1) in the Datagrid and transfers it to cell
"G9"
in Excel


"Roger Govier" wrote:

Hi

I think you would need a

.Sheets("Sheet1").Activate or .Select
before referring to the individual cell ranges.

--

Regards
Roger Govier

"Stumped Programmer" <Stumped wrote
in
message ...
I am wondering how to use excel's automated reference to automate
updating
data in a excel file using access.

Ex: Using the ".Range("G9").Value ="

I have personally tried using this code (it did not work)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

With objExcel
.Visible = True
.Workbooks.Open("\EDV SUMMARY SAMPLE.xls")
*.Range("G9").Value =
Val(EDV_DMM_STD_SummaryDataGridView(3,1))*
.Range("A1").ColumnWidth = 20
.Range("A1").Font.Bold = True
.Range("A2").Value = "So. Main St."
.Range("A3").Value = "Hartford" & ", " & "CT"
End With

**this is a control table conected to a linked databse. I am
trying
to point to a cell in the table by using indexes and write the data to
the
excel doc.





Stumped Programmer[_2_]

Importing Access to Excel
 
G9 is on sheet one. I do not have a problem writing to sheet one in general,
my problem is writing to sheet one with data from a datagrid.

"George Nicholson" wrote:

I am trying to take the value
(text or integer) of cell (3,1) in the Datagrid and transfers it to cell
"G9"


Yes, but "G9" on WHAT SHEET?

*Assuming* objExcel is properly declared as Excel.Application somewhere
else(since it isn't declared in the supplied snippet) then:

objExcel.Range("G9").Value = yada yada

is the same as

Application.Range("G9").Value = yada yada

That simply doesn't tell Excel what your intentions are.

I'm guessing you are getting a 1004 error which usually translates as "You
haven't given me enough information. I don't know what (or which) object
you're trying to reference. Please be specific."

Again, that's an assumption. You say "it did not work", which is, again, a
little light on information. (it threw an error?, did nothing?, did
something other than intended?, crashed? etc.)


--
HTH,
George


"Stumped Programmer" wrote in
message ...
Thank you,

The cells I am refering to are in a Datagrid (stated "table" in post) in
my
project.
With the line: *.Range("G9").Value =
Val(EDV_DMM_STD_SummaryDataGridView(3,1))* I am trying to take the value
(text or integer) of cell (3,1) in the Datagrid and transfers it to cell
"G9"
in Excel


"Roger Govier" wrote:

Hi

I think you would need a

.Sheets("Sheet1").Activate or .Select
before referring to the individual cell ranges.

--

Regards
Roger Govier

"Stumped Programmer" <Stumped wrote
in
message ...
I am wondering how to use excel's automated reference to automate
updating
data in a excel file using access.

Ex: Using the ".Range("G9").Value ="

I have personally tried using this code (it did not work)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

With objExcel
.Visible = True
.Workbooks.Open("\EDV SUMMARY SAMPLE.xls")
*.Range("G9").Value =
Val(EDV_DMM_STD_SummaryDataGridView(3,1))*
.Range("A1").ColumnWidth = 20
.Range("A1").Font.Bold = True
.Range("A2").Value = "So. Main St."
.Range("A3").Value = "Hartford" & ", " & "CT"
End With

**this is a control table conected to a linked databse. I am
trying
to point to a cell in the table by using indexes and write the data to
the
excel doc.






All times are GMT +1. The time now is 10:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com