VBA - Save File As New Workbook BUT Without Existing Data Connections

May 23, 2013

I'm trying to use vba to create an offline backup file for a sheet that is linked to an access database. the code I have is simple and worked for a file that is not linked to any database.

Code:
Sheets("Data").Select
Sheets("Data").Copy
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=myfilename
Application.DisplayAlerts = True

Now that I insert it into the actual file, which is linked to the database I get an error. I also tried to move the display alert up, before the select instructions, but also this does not work. this is not what I wanted since I want this file not to possibly connect to any database.

View 9 Replies


ADVERTISEMENT

External Data - Cleanup Existing Connections

Apr 26, 2013

While making my first foray into defining external connections (to an Oracle database) I ended up with an "Existing Connection" that reports "File could not be opened. It is either damaged or the file format is not valid. Try opening the application that created it and saving to a new file." Followed by "Unable to open or read this connection file. Either the file has been damaged or the file format is not valid."

Ok, fine. So how do I delete it? There seems to be no option for that in the "Existing Connections" dialog. A search for a *.odc or *.udcx file doesn't turn up anything with the name of this connection. A search of the registry doesn't turn up anything.

extdata.jpg

View 1 Replies View Related

Closing Existing Connections To Access Databases

Jan 17, 2014

I've created several access databases to which I've connected my excel files. However I've either deleted/moved these databases but my connections are still showing in Data -> Existing Connections tabs.

I've tried going to C:Program FilesMicrosoft OfficeOffice14QUERIES but no such queries exist.

Is there any way to clear my list ?

View 2 Replies View Related

VBA To Change Workbook Data Connections

Jun 2, 2014

My issue is we have a remote office, using an access DB which links to an Excel file. We sometimes send the files to other people to make changes, but the link is then broken (it was a network location).

You can just change it manually, or accept the many prompts that come up, but it needs doing at each end, each time.
I thought I'd do a routine to change the connection paths, this is what I have...

Code:
Sub alan()
Dim i As Long
Dim cnt As Long
Dim modtext As String, modfile As String
Dim modrange As String, OldPath As String, NewPath As String

OldPath = "\192.168.1.100MultimediaCommissioning Folder"
NewPath = "C:matts"

[Code] ...

I added the sourcedatafile part to the routine afterwards, because the connection string part worked fine. But I now get Run-time error '1004' Application-defined or object-defined error...

View 3 Replies View Related

Removing Data Connections And / Or Query Tables Before Saving File?

Oct 10, 2013

I've tried to remove connections after saves and have been unsuccessful.

HTML Code:
' Delete Additional Connections
' If ActiveWorkbook.Connections.Count > 0 Then
' For i = 1 To ActiveWorkbook.Connections.Count
' ActiveWorkbook.Connections.Item(1).Delete
' Next i
' Else
' MsgBox ActiveWorkbook.Connections.Count
'
' End If

HTML Code:
' Remove named ranges
For Each nm In ActiveWorkbook.Names
nm.Delete
Next nm

I've tried both of these and the Excel file is still attached with XML to the query table. I get an error message saying the format is different then if you click okay it shows its connected to the database still. Is there an aggressive command that will severe all connections before saving? What commands to run to stop this connection after save to another workbook?

View 2 Replies View Related

Macro To Save Workbook By Referencing Cell In Another Workbook For File Name And File Path

Mar 21, 2013

I have got a master workbook and I have written macro to copy and paste data on another workbook. write a macro to save the new workbook to a file path with a file name where both file name and path are stored in master workbook sheet...

View 5 Replies View Related

Open / Refresh Connections To ODBC - Recalculate One Sheet / Save And Close

Mar 25, 2014

I am using Task scheduler to open a workbook which has some connections to an ODBC that are set to refresh on opening.

I need to automate:-

One of the sheets needs to recalculate for the sort by ascending code to run on the sheet.

Save and then close after say 2 minutes of opening (to give the ODBC connections enough time to finish).

View 2 Replies View Related

Copy Data From Workbook / Open Existing Workbook - Select Range And Paste

Mar 26, 2012

Copy data from workbook, open existing workbook, select range and paste. But my copied data is lost.

Sub Select_Copy_Paste()
'
'
Windows("ElektroFunctiesDatabase.xlsm").Activate
Sheets("PowerSupply's").Select
Range("A2:I6").Select
Selection.Copy

[Code] .........

' Here i need to do something to paste data into r.address?

View 4 Replies View Related

Slicer Connections Lost When Copying To New Workbook

Jun 12, 2014

The main objective of the code is to create different workbooks that are going to be send to different people(with only their data).

I am using the filter to delete the data that I don't need and then create a new workbook, save it and close it. This has been working fine.

The issue is that I have two slicers in the 'DistMenu' sheet. When I open again the newest workbook, they slicers are disconnected to the pivot tables. This can be fix manually by selecting the slicers --> PivotTables Connections etc

I use the macro recording to get a code and work from there, but is giving me error '1004' "Unable to get the PivotTables property of the Worksheet class".

View 1 Replies View Related

Save A Single WorkBook Tab To A New File

Aug 28, 2008

I am using Excel 2003 and need to save via VBA code a single tab in a workbook to a new workbook. I need to be able to specify the new workbook file name and location. The copy feature on the tab won't work because the data is too large and I get an ugly message using that option.

View 9 Replies View Related

Excel 2007 :: Delete ALL Connections In Workbook Without Having To Specify Names

Oct 20, 2008

The following code deletes a specific connection in a workbook:-

ActiveWorkbook.Connections("text123").Delete

How can I code this so that I can delete ALL connections in a workbook without having to specify the names (as these will always be different).

View 3 Replies View Related

Copying Range Of Data Into Another Master Workbook Below Existing Data

Mar 21, 2014

I have a range of weekly data that I need to copy into another workbook, paste it below the data that already exists there and then delete the data from the original workbook. I would love to do this with vba but after hours of searching on how to do this my brain is frazzled.

I have 50 workbooks that I need to import weekly into one master sheet (Master.xlsm) but they need to be done individually after the weekly data has been checked. The master sheet will therefore have existing data and the new data needs to be appended at the bottom. Also column A will be blank in both workbooks so to find the last used row it will need to look in column B.

The number of rows in the weekly sheet will also vary rather than be a fixed range so I guess the last used row will also need to be found there too.

The attached file is a cut down version of my working file showing where the data starts on Row 14, I won't need to copy the headings.

Example file 21.03.xlsm‎

View 4 Replies View Related

Create New Workbook From Existing Worksheet Data

Feb 17, 2009

I am working on this estimating template. To be used on Excel 97, 2000 and XP systems.

I have a few issues i am unable to resolve.

There are 2 of the worksheets (Short Quote and Stores Req) which individually need to have a button on them so i can create a new workbook as an exact coy of that sheet. but with just the values and not the formulas.

Also i am unsure on the macro on the workbook currently( as i dont know how to do macros) i dont know what it does?

View 7 Replies View Related

Macro To Save Workbook/File As Cell Value

Sep 15, 2006

I need to be able to save a workbook by running a marco and it save the file automatically by pulling what ever the value of cell A1 is.

Ex: I want to run the macro and it save my excel workbook in C:Documents as (Value of Cell A1) What code would you put into Visual Basic.

View 3 Replies View Related

Copy Into New Workbook & Save With Date In File Name

Aug 7, 2008

I have a report which I have written a macro to reformat, I then want to copy the sheet (Remake) containing the report into a new workbook as the only sheet in the new workbook. I want the sheet name to be changed from "Remake" to "Duty to Consider" and I want the new workbook to save itself automatically as "Duty to Consider - Month/Year" - in this case it would be "Duty to Consider - August 2008".

I think that a Pop Up box which lets me input the Month and Year of the report I am working on would be useful in naming the new workbook, if this box popped up when I click the button which runs my Macro that'd be great. Here is the code I am using to reformat my report. This works fine I just need the changes I mentioned. Application. ScreenUpdating = False 'this will turn on screen updating, making the macro run faster

'This will select the DTC Tab and remove rows 1-4
Sheets("DTC").Select
Rows("1:4").Select
Range("A4").Activate
Selection.Delete Shift:=xlUp

'This will add a filter to the data to remove duplicate rows
Range("A1").Select
Range("A1:J1307").AdvancedFilter Action:=xlFilterInPlace, Unique:=True

'This will copy the data on the DTC tab and copy it into the Remake Tab
Cells.Select.....................

View 2 Replies View Related

Opening Excel Workbook With Embedded Connections Using VBA And Auto Refreshing

Apr 3, 2014

I have an Excel Workbook with Showcase Queries embedded into it.

Upon a manual open, the user is prompted to either refresh data or keep data since last save, the user then has to enter a username and password to allow the query to access the database.

Using the code below to open the workbook, no such prompts are given. Is the code overriding the prompts and automatically refreshing the data without password? [Given nature of data, visual validation of refresh is not possible]

If not, how can we code a data refresh through showcase query with user/pw req's?

[Code] ......

View 1 Replies View Related

Macro - Importing CSV File Into Specified Worksheet Overwriting Existing Data?

Sep 5, 2013

- Construct a macro to import a csv-file to my worksheet named "Info". The data in the .csv-file should start in row A5 in my worksheet.

- If the worksheet "Info" already has data, I want to overwrite the existing data with the new data starting in row A5

The directory of the csv-file is C:Testmycsvfile.csv

View 3 Replies View Related

Userform To Fill Data Entered Into Different (existing) Workbook?

Feb 7, 2013

I have a userform that I want to add to a button click event, to fill userform data into a different (already existing) workbook.

What I have is a userform for entering Purchase order information (Supplier, Date, PO#, Products, Descriptions, Qty's, expected dates etc.) What I am trying to accomplish with this particular button, is to 'Generate Purchase Order'... Have a seperate workbook, with a 'blank' pre-formatted formal purchase order that will be autofilled with said userform. The now generated Purchase Order ready for print/ save-as.

View 1 Replies View Related

Save Workbook To Desktop If File Doesn't Exists

Sep 22, 2009

I'm having a slight problem with this script. What I'm looking to do is before the workbook is closed is check to see if the workbook already exisits on the users desktop if it doesnt then save it to the users desktop. if is does exists then just exit the sub. Here is what I have so far but for some reason it kept displaying the aleart message that the file already exists and wants to save it again.

I just added the displayalerts = false in but the script still does not know that file already exists. So when the file is closed it keeps saying file has been placed on your desktop.

View 3 Replies View Related

Create & Save Workbook To Same Path As Macro File

Aug 21, 2008

I have code to create a new workbook, and when I try to rename it I get "Compile error: Can't assign to read-only property."

Dim objXlApp As Object
Dim wkb As Workbook
Dim wks As Worksheet
Set objXlApp = CreateObject("Excel.Application")
' Create a workbook
Set wkb = objXlApp.Workbooks.Add
' Delete all worksheets bar the first one.
For Each wks In wkb.Worksheets
If Not wks.Index = 1 Then
wks.Delete

End If
Next wks
'Create some worksheets and names
With wkb
.Worksheets(1).Name = "myWorksheet1"
.Worksheets.Add.Name = "myWorksheet2"
.Worksheets.Add.Name = "myWorksheet3"
.Worksheets.Add.Name = "myWorksheet4"
End With...................................

View 5 Replies View Related

Save Workbook With Current File Name To Specific Folder

Dec 4, 2007

I recorded a macro to save a workbook to a specific folder using the current file name. However, I've tried to remove the absolute reference to a specific filename but it is not working for me. Am I close?

ActiveWorkbook.SaveAs Filename:= _
"H:Files and DocumentsPROJECTSSR 2 SS Phase Two Component ReliabilityWinTrac Files xt_conversionsexcel_version" & SheetName _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

View 2 Replies View Related

Save File / Workbook As Cell Reference Filepath & Name

Feb 8, 2008

I'm trying to get Mac OS X Excel VBA to understand this code however the ChDir reference and the filepath seem to be causing problems. I would like to specify in the code where the file should be stored but I did try removing the filepath section altogether but to no avail.

Option Explicit
Sub SvMe()
'Saves filename as value of A1 plus the current date
Dim newFile As String, fName As String
' Don't use "/" in date, invalid syntax
fName = Range("A1").Value
'Change the date format to whatever you'd like, but make sure it's in quotes
newFile = fName & " " & Format$(Date, "mm-dd-yyyy")
' Change directory to suit your PC, including USER NAME
ChDir _
"C:Documents and Settings USER NAME Desktop"
ActiveWorkbook. SaveAs Filename:=newFile
End Sub

View 2 Replies View Related

Macro To Save As Workbook 2 From Data In A Cell From Workbook 1

Sep 28, 2012

I have two workbooks open. I need to "Save As" and close workbook 2 with a file name from a cell in Workbook 1. The macro is running from workbook 1.

I'm guessing a change in the last line. I don't know what Dim means either.

Dim FName As String
Dim FPath As String

FPath = "G:"
FName = Sheets("sheet 1").Range("A1").Text
ThisWorkbook.SaveAs Filename:=FPath & "" & FName

View 1 Replies View Related

How To Enable Data Connections

Dec 16, 2011

I have a workbook which uses data connections to our sage accounts product. Everytime i open the sheet i get the "Data Connections have been disabled" security message, and need to go in and enable them. Is there any way of enabling the data connections by default? I only want to do it for this one workbook - i still want to be prompted when i open other workbooks.

View 2 Replies View Related

Save Data From One Workbook To Another Without Opening Workbook

Mar 1, 2013

I have a spreadsheet that data gets exported to from a software program. There is information such as customer name, part number, inquiry number, etc that I'd like to use to develop a log of all my estimates I create for parts. I'd like excel to take the cells I select and insert them into certain cells in the other workbook and automatically save that workbook. This will create a log of all my estimates where I can then link the full estimate to the log. The information will have to go in the next available row. Is there any way I can accomplish this without having to open the other workbook and save the work book each time?

View 1 Replies View Related

Close Data Connections After Refresh

May 3, 2013

I currently have a spreadsheet that has data connections to a file on a shared drive. On opening the file I have it update the data connections so that the data needed is always correct. The file I use is to be distributed out to work colleagues to use and on testing it works really well apart from if you have the file open and somebody tried to open the original file where the data is pulled from for the connection. It says it currently in use by 'another user'.

Is there any code to add to workbook_open that will close/disable the data connection links once the data has been updated? The code I currently have is this:

VB:
Private Sub Workbook_Open()
ActiveWorkbook.RefreshAll
Application.Wait Now + TimeValue("00:00:02")
Userform1.Show
End If
End Sub

What this basically does is gives it time to refresh the data connections and show a progress userform. The only thing is the connections stay live and I don't want that as the connection file is then locked. I'm hoping its something simple like ActiveWorkbook.CloseDataConnection added in after the userform has been shown (or something along them lines ). Also the data connections would have to be able to reconnect on open so that they can refresh again.

View 5 Replies View Related

Editing Data Connections In 2003

Oct 20, 2009

I have a workbook with multiple worksheets and over 25 Data Connections using MS Query to connect to different tables in an SQL Server database.

The problem is that the SQL Server database is now being moved to a different server. The database name and the schema of the tables will be unchanged. Only the server name needs to be changed from XXXXX to YYYYY.

I have been unable to find a way to successfully edit the data connections in Excel 2003. A web search produced one potential option. However, that did not work for me very well. Thought the code is designed to cycle through all tablequeries and pivotqueries, the change is only made to one of the data connections. Here is the option I tried:

http://support.microsoft.com/kb/816562

Note that it is very easy to edit data connections in Excel 2007. So I also tried opening the .xls file in Excel 2007. I used the Data Connections button under the Data tab in the ribbon and was successful in editing the connections to point to the new server. However, the graphs used to display the queried data behave weird. The "format axis" settings and chart sizes change. In general, default display settings for charts seems to differ between Excel 2003 and 2007.

I used Excel 2007 to only edit the data connections and saved the workbook in the original .xls format

View 3 Replies View Related

Save .txt To .xls Using Existing Name And Path

Apr 18, 2007

how do i save a text file to xls in code. i want the new .xls file to appear alongside the original .txt file.

View 9 Replies View Related

Create Fillable Pdf File From Existing Excel Xlsm File?

Feb 25, 2014

I have a macro enabled file with some functions. Now I want to create a fillable pdf file from this file.

I am able to create a pdf file from Excel 2007, but not able to make a fillable one

View 1 Replies View Related

Macro To Delete All External Data Connections

Mar 31, 2009

I am trying to write a macro to delete all connections from a very large excel file

I created this file by using a Macro to extract data from a external data source (url's listed on a sheet)

The issue is the 1000+ connections on this file make it next to impossible to operate

I cannot recreate the file

macro to delete all connections in all sheets in a given work book.

[URL]

Macro used :

Sub Dump()
Dim myURL
Sheets("Sheet1").Select
ActiveCell.Offset(1, 0).Select
myURL = Worksheets("Sheet1").Range(ActiveCell.Address).Text
Sheets("Sheet2").Select
Range("A65536").Select

[code].....

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved