shieldsco
asked on
Delete Excel Column From Access
I need to delete an Excel column (P) from MS Access using VBA. Any thoughts. After deletion I need to save the WB and close Excel.
ASKER
I'm using Access and I want to delete an Excel column using Access VBA. If this helps, I'm using the following code to to convert two Excel columns to text using VBA from an Access button.
'Convert Columns A and B to Text
Private Sub Udate_Click()
Set objApp = CreateObject("Excel.Applic ation")
objApp.Visible = False
Set wb = objApp.Workbooks.Open("\\c dc\project \OD_FMO_DE BT_MGT\Cas h Recon Database\General Fund FOIA.xlsx", True, False)
wb.Sheets(1).Range("A:B"). NumberForm at = "@"
wb.Save
wb.Close
objApp.Quit
Set objApp = Nothing
'Convert Columns A and B to Text
Private Sub Udate_Click()
Set objApp = CreateObject("Excel.Applic
objApp.Visible = False
Set wb = objApp.Workbooks.Open("\\c
wb.Sheets(1).Range("A:B").
wb.Save
wb.Close
objApp.Quit
Set objApp = Nothing
ASKER
I figured it out -- thanks. Here is the code
Private Sub Command0_Click()
Set objApp = CreateObject("Excel.Applic ation")
objApp.Visible = True
Set wb = objApp.Workbooks.Open("\\c dc\project \OD_FMO_DE BT_MGT\Cas h Recon Database\General Fund FOIA.xlsx", True, False)
Columns("P:P").Delete
wb.Save
wb.Close
objApp.Quit
Set objApp = Nothing
End Sub
Private Sub Command0_Click()
Set objApp = CreateObject("Excel.Applic
objApp.Visible = True
Set wb = objApp.Workbooks.Open("\\c
Columns("P:P").Delete
wb.Save
wb.Close
objApp.Quit
Set objApp = Nothing
End Sub
If you worked out a solution, then there should be no reason to accept my comment at all.
I have used the "Request Attention" link above to ask for the question to be re-opened, so your own comment can be accepted (& so you do not use any of your points on this question).
I have used the "Request Attention" link above to ask for the question to be re-opened, so your own comment can be accepted (& so you do not use any of your points on this question).
I've requested that this question be closed as follows:
Accepted answer: 0 points for shieldsco's comment #a39605507
for the following reason:
Starting closing process on behalf of Asker.
Netminder
Senior Admin
Accepted answer: 0 points for shieldsco's comment #a39605507
for the following reason:
Starting closing process on behalf of Asker.
Netminder
Senior Admin
ASKER
I figured it out -- thanks. Here is the code
Private Sub Command0_Click()
Set objApp = CreateObject("Excel.Applic ation")
objApp.Visible = True
Set wb = objApp.Workbooks.Open("\\c dc\project \OD_FMO_DE BT_MGT\Cas h Recon Database\General Fund FOIA.xlsx", True, False)
Columns("P:P").Delete
wb.Save
wb.Close
objApp.Quit
Set objApp = Nothing
End Sub
Private Sub Command0_Click()
Set objApp = CreateObject("Excel.Applic
objApp.Visible = True
Set wb = objApp.Workbooks.Open("\\c
Columns("P:P").Delete
wb.Save
wb.Close
objApp.Quit
Set objApp = Nothing
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, but your requirement is not completely clear (to me).
How is column [P] within the MS-Excel workbook associated/linked with a column within an MS-Access database table?
Have you already opened a connection to the database &, hence, do you just need help with the code to remove a column from the MS-Access database schema (table definition)?
Thank you for your clarification & provision of all the relevant details to proceed.
BFN,
fp.