help with a macro

Joe C

Well-known Member
Joined
Oct 17, 2002
Messages
841
Based on code from a board advisor I am trying to run the below macros.
But My system freezes when it gets to

workbooks.Open filename:=savename

not recognizing the name. Can anyone explain what I did wrong??
Here is the complete module.

Option Compare Database
Option Explicit

Sub spine()
Dim excelsheet As Object
Dim savename As String
Call XLLibrary
savename = InputBox("Path and File Name", "C:\filename")

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "qtable1", savename, True

workbooks.Open filename:=savename

Set excelsheet = workbooks.Application.activeworkbook

With excelsheet
.Application.Visible = True
sheets(1).range(cells(1, 1), cells(2, 8)).font.bold = True
.Save
.Quit
End With
End Sub

Sub XLLibrary()

On Error Resume Next
Application.References.AddFromGuid "{00020813-0000-0000-c000-000000000046}", 2, 3

End Sub
End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I tried that does not seem to be the answer. Is there a better command to open the excel file.
IT does not seem to understand
Workbooks.Open.
I get a 424 error code.
 
Upvote 0

Forum statistics

Threads
1,221,510
Messages
6,160,226
Members
451,632
Latest member
purpleflower26

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top