Over 1 million tech questions and answers.

Open an excel workbook which contain macro from vb

Q: Open an excel workbook which contain macro from vb

Good Day Moderator,
just got to the core... I've problem to open an excel workbook which contain macros from visual basic at run-time. Thats it, I don't know what properties or method that I should used.

For your illustration, perhaps I should write some of them in here ( hope you don't getting bored with this )

dim strFile as String
dim objExcel as Excel.Application

strFile = InputBox("Please input your excel file full path :","C:\")

Set objExcel = CreateObject("Excel.Application")

With objExcel
.DisplayAlerts = False
.Workbooks.Open strFile

MsgBox "Your name is : " & .ActiveSheet.Range("D1")

.ActiveWorkbook.Close False
End With

While trying to process the Msgbox's function, it said that "Object variable or With block variable not set", just like if the object has not successfully created.

Do you have any idea with this ? I really don't know what to do.
Thanks a lot for your help and have a nice day

Best Regards.

Preferred Solution: Open an excel workbook which contain macro from vb

I recommend downloading and running Reimage. It's a computer repair tool that has been proven to identify and fix many Windows problems with a high level of success.

I've used it in the past to identify and fix everything from blue screens (BSOD's), ActiveX errors, corrupt files and processes, dll/exe/sys errors, recover lost memory, Windows update problems, defragging, malware removal etc.

You can download it direct from this link http://downloadreimage.com/download.php. (This link will automatically start a download of Reimage that you can save to your computer.)

A: Open an excel workbook which contain macro from vb

I don't claim to do VBA, but I dabble.

In the first place, if you are creating this code in an Excel file, I don't think you need to declare Excel as the application at all.

I think you should be creating a workbook object and not an application object.

I just tried it out, and I get that darn Error 429, but I think that's better than what you're getting.

Read other 1 answers

Hi There

I have recorded a macro that opens up a workbook from my C drive as follows:

Workbooks.Open Filename:= _
"C:\Documents and Settings\Mario Pincivero\My Documents\Homes\Salem's Point 1L 40M-2423.xls"

I also recorded a macro that opens a workbook from windows as follows:

Windows("Salem's Point 1L 40M-2423.xls").Activate

I want to combine these two macros to do the following:

If Salem's Point 1L 40M-2423.xls is aready open then do the code Windows("Salem's Point 1L 40M-2423.xls").Activate

If Salem's Point 1L 40M-2423.xls is not open then do the code Workbooks.Open Filename:= _
"C:\Documents and Settings\Mario Pincivero\My Documents\Homes\Salem's Point 1L 40M-2423.xls"

Please help


A:Excel Macro to open a workbook

Hi Mario,

When you say you open a workbook from your C-drive.
Are you executing your macro from within an Excel workbook or how?
What do you trigeer it with or where do you trigger it from?

Read other 1 answers

Using Excel 2010. I regularly download data from a database which have to be sorted by

column 1 - cell color blue on top, then
column 1 - cell color orange on top, then
column 4 - value, from newest to oldest

the data is always downloaded automatically to a workbook named "ABC", and the worksheet is always automatically named ABC#, with the # changing automatically.

the macro is saved in the personal folder. I tried to record using absolute and then as relative reference. the macro NEVER works when I tried to run in any new downloaded workbook or even I recreated the same data in a new untitled workbook.

the number of columns is always the same but the number of rows varies. there are about (7) cell colors, but only the blue and the orange need to be on top

the recorded macro always indicate the name of the worksheet and workbook on which it was created. is this why it does not work on any other workbook or worksheet?

any help will be appreciated

A:Excel Macro Won't Open in Different Workbook

Read other 14 answers

I work with Excel 2010 and have a series of workbooks (preop_management_AAA.xlsm, preop_management_BBB.xlsm, preop_management_CCC.xlsm) that each have a worksheet named 'Medications.' From the 'Medications' sheet, I have a macro in each which opens a common workbook named bridging.xlsm. After doing calculations in bridging.xlsm, the user returns to the workbook from which they started and proceeds to the next worksheet in the original preop_management_xxx.xlsm workbook via a macro named 'NextFromMedications.' Only one of the preop_management workbooks will be open at any one time.

I need help writing code that will call the 'NextFromMedications' macro in the open preop_management_xxx.xlsm workbook from the bridging.xlsm workbook. While the name of the macro is the same in each of those workbooks ('NextFromMedications'), the file name is variable so if I write (in bridging.xlsm) something like
Application.Run "'preop_management_AAA.xlsm'!NextFromMedications"
the macro would only work for one of my three "originating" workbooks. I am looking for a way to "generically" refer to the file name in the 'NextFromMedications' macro.

I cannot put the 'NextFromMedications' macro in my PersonalMacro workbook since these workbooks will be used by multiple users on multiple computers.

As always, I thank you in advance for your time and consideration.

A:Solved: Running a macro in a different open Excel workbook

Read other 10 answers

Hello Everyone

I am having some difficulties finding a solution to my problem. I am hoping someone can help or lead me to the right direction.

I have a workbook called Data.xlsm, below is a sample:

ID, Name, commission
1 john 1000
2 eric 2000
3 ryan 3000

Now I have another excel file called Temp.xls which looks pretty much the same as Data.xlsm.

ID, Name, Commission
1 john 200
2 eric 300

I need a macro that will read the Temp.xls and grab the commissions and bring them to Data.xlsm. The commissions need to be summed based on ID.

The final Result on Data.xlsm should be as follows:
1 john 1200
2 eric 2300
3 ryan 3000

Any help would be greatly appreciated.

Thank you

A:Solved: Excel Macro - Upload Workbook value from Another Workbook based on ID

Just a quick and dirty solution

Make sure you place this in the same folder as your Temp.xlsm file and press the button

It will open Temp
update the data, if a new Id is in Temp it will add the data and set the commission values in Temp to 0 to avoid running it twice.

I hope the code explains itsefl.

Think of a macro of a step by step instrcution as you would say it out loud.

Read other 3 answers

I have an Excel macro that opens another workbook. If the macro errors out, how can I close the second workbook that was opened?

A:Excel Macro -> Close Second Workbook

Read other 12 answers

I have a workbook that I want to share with many people so they can all edit at same time. When I share it, they cannot run macos, it errors out with

"Error 1004 Application defined or object defined error"

Any ideas on how to overcome this?


A:Excel - Shared Workbook Macro

The macro is supposed to create hyperlinks... is this a no no? this is excel 2007...

Read other 1 answers

I am copying an excel worksheet from an existing workbook to a new workbook using a macro. The sheet contains a Private Sub. I want the new workbook to have the Private Sub password protected. Is there a way of writing this into the macro of the originating workbook?

Read other answers

I have a audit template that takes two files and compairs them and opens a new workbook to display the differences. This new workbook is then saved to a specific location for audit reasons.

In the new workbook created, I'm wanting to "remove" all the toolbars and menus so a user can't safe the file to another location by mistake.

Is there a way for the creating template to "insert" macros into the newly created workbook to do this? While I could just create new worksheets in the "creating" template workbook and remove the ones I don't need, I'm trying to keep the size of the file down by not having all the macros that created the new template in the final product.

A:Have Excel VBA Create A Macro In A New Workbook

Just for some thoughts on this concept, I would suggest you read this:

Read other 1 answers

I was wondering if it was possible in excel to have a main main with buttons that direct you to different tabs.

Once you get to that tab, the person needs to insert the correct password for that correct tab.

I have created a macro. It is located in the view code right next to File in the upper left hand corner.

Is it possible also, that if the administrator enters in a password somewhere in the Sheet 1 where all the buttons are, that the administrator can have access to all of the sheets without inserting a password.

The password for Sheet 2 is Sheet2.

The password for Sheet 3 is Sheet3.

A:Excel Macro for protecting sheets within a workbook

You might want to read:

Particularly, the part about "Projects".

Anyway, sure you can do this, but it'll take some code and not everyone has the time (or is willing to spend the time) to write that code FOR you. You can, however, check this out:

Use a sample file. Then, if you can't get it to work perfectly, ask at that forum (OR HERE) for additional help, uploading the sample file.

I hope this kick-starts you.

Read other 3 answers

Is there a macro that can be created to move the currently opened workbook to a different folder?

A:Solved: Excel Macro -> Move Workbook

Just issue the save as command to save the workbook to the new location with the same or new filename and then delete the old workbook

Sub MoveWorkbook()

vOriginal = ActiveWorkbook.FullName

ActiveWorkbook.SaveAs ("C:\NewName.xls")

Kill (vOriginal)

End Sub
Sub MoveWorkbook()

vOriginal = ActiveWorkbook.FullName
vWB = ActiveWorkbook.Name

ActiveWorkbook.SaveAs ("C:\NewFolder\" & vWB & ".xls")

Kill (vOriginal)

End Sub

Read other 3 answers

How will I write a macro in excel that will enable me to save a current workbook in a specified directory and use the wording in a cell on the spreadsheet as the file name.

I have tried copying a macro and have got as far as the new directory, but do not know how to name the file after wording in a cell in a spreadsheet.

A:Macro to save excel workbook as name in cell on spreadsheet

Just one simple line. Just change the portions in red to reflect your true save path and cell to use. You may need to also change the xls file extension if you are using Office 2007 or newer.
ActiveWorkbook.SaveAs Filename:="[COLOR="Red"]C:\TEST\[/COLOR]" & Range("[COLOR="Red"]A1[/COLOR]").Text & ".xls", FileFormat:=xlNormal


Read other 1 answers

Mods please delete this!!!!

Double post, sorry...

The original post can be found here.


Read other answers

I have XP and just installed Office 2007. In order to get a 2003-like environment, I set up a customized Quck Access Toolbar that is meant to come up every time I open Excel. I also have a Personal Macro Workbook I wish to automatically open every time I open Excel.

To do this, I set them up as Add-ins in the ...\Application Data\Microsoft\AddIns\ directory:
* PersonalMacroWorkBook.xlam
* MyQAT.xlam

The issue is that when I launch Excel directly (say, from the Start Menu), the two add-ins open and work. However, if I launch Excel by directly opening an Excel file, neither of the two add-ins are opened. [Note that this happens whether I'm opening file with extension .xls, .xlsm, or .xlsx.]

One other point - this used to work just fine. The issue arose recently - and I think I can trace it back to Excel crashing a few days ago. It crashed, incedentally, independent of any action by me - I was actually working in a different application at the time.

Can anyone tell me what's going on? Can you help me fix this?


Read other answers

Is there a way to save a workbook if a cell within a range is changed?

A:Solved: Excel Macro -> Save Workbook On Cell Change

Read other 16 answers

I'm retrieving some data from some CSV files using a macro.

Everything works fine, but it appears that just opening a file causes the entire workbook which the macro is being run from to get re-calculated, even though I'm not even changing any values (yet)!?!?

I assume it's every table value in every worksheet which uses a formula whenever I open a file (and this is in a new window)!!! As I'm opening 7 files, repeatedly calculating values unnecessarily (7 times!!!) even though doesn't appear to take much time, it's still time better spent doing something else.

The code I'm using to open the file:

Workbooks.OpenText Filename:=bk, Origin:=437, StartRow:=1 _
, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=True, _
Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array( _
3, 2), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1)), _
bk is the file reference getting passed in. Bear in mind that everything does work and I'm using Excel 2007 under XP.

Any help would be greatly appreciated.


A:Solved: Opening CSV through Excel macro causes the entire workbook to get re-calculat

Read other 13 answers


I have a corrupted Microsoft Excel Macro-Enabled Workbook xlsm file. Does anyone know how i can restore or recover it please?

A:Corrupted Microsoft Excel Macro-Enabled Workbook xlsm file

You can see here http://www.mathworks.com/matlabcent...rosoft-excel-macro-enabled-workbook-xlsm-file

Read other 1 answers

I am getting a message, when I close Excel 2016, asking if I want to save changes to my Personal Macro Workbook, but I have not made any changes. Is there any way to get rid of this message, other than to click Save (I would have no idea what I am saving).


Read other answers

Hi all,

I really need help with this, as I have tried means to get it right, but I have no experience in VBA and it seem difficult. Any help will be greatly appreciated.

I need to copy specific cells in a form (in Excel format) that is input by users and paste them into the summary workbook.

The form is fixed, but every time someone sends in a new form, I'll need to update the data in a summary workbook. So it'll be constant updating and I need to ensure that a new row in the Summary folder is used for each form that is sent in.

I'm trying to write a macro that is able to automate the data transfer.

Eg. I need to:

copy the data from D6 in the file Form to the celll A2 Summary file,
D7 in Form to B2 etc.
Attached is the form and my summary sheet.

Thanks in advance!

A:Help Needed for Excel Macro - Copy specific cells and paste into a Summary workbook

Hi all,

Below is the vba code that I have written.
But the problem is I am not sure how to define the destination workbook as a file, which is also where this macro will be stored.

It does not seem to work when I tried to put ThisWorkbook or Activeworkbook. I did not want to add a new workbook either.

Sub copyWorkbooks()
Dim MyPath As String
Dim SourceRcount As Long, FNum As Long
Dim mybook As Workbook, DestWks As Workbook
Dim sourceRange As Range, destrange As Range
Dim rnum As Long, CalcMode As Long
Dim SaveDriveDir As String
Dim FName As Variant

' Set application properties.
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
End With
SaveDriveDir = CurDir
' Change this to the path\folder location of the files.
ChDirNet "C:\Documents and Settings\chinba\Desktop\ASL Exception\"
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xl*), *.xl*", _
On Error Resume Next

'find the last row
RDB_Last = rng.Find(What:="*", _
after:=rng.Cells(1), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
On Error GoTo 0
If IsArray(FName) Then
'Loop through all files in the myFiles array.
For FNum = LBound(FName) To UBound(FName)
Set mybook = Nothing
On Error Resume Next
Set mybook = Workbooks.Open(FName(FNum))
On Error GoTo 0
If Not mybook Is Nothing Then
On Error Resu... Read more

Read other 1 answers

Hi There
I have searched the internet to see if I could find a macro that opens a workbook and runs a macro. In other words, I have workbook 1 (master workbook) and workbooks 2,3,4 ...1000. So far I found a macro that opens workbooks 2, 3, ...1000 by running a macro from workbook 1. Now I have a macro in workbooks 2,3,....1000. What I want is to run the workbooks 2,3,...1000 macro from workbook 1. I can do it if I call the workbook name. But I don't want to do that, since I have over 1000 workbooks. Below is the code.

Sub WWNumbers()

Dim fso As Object 'FileSystemObject
Dim fldStart As Object 'Folder
Dim fld As Object 'Folder
Dim fl As Object 'File
Dim Mask As String
Dim thisFolder As String
Dim fullFilename As String

Set fso = CreateObject("scripting.FileSystemObject") ' late binding
Set fldStart = fso.GetFolder("C:\Users\Mario\Documents\Folder1 Name\Folder2 Name")
Mask = ActiveCell.Value
thisFolder = fldStart & IIf(Right(fldStart, 1) = "\", "", "\")
Debug.Print thisFolder, Mask
If Not IsError(Dir(thisFolder, vbReadOnly)) Then
If Dir(thisFolder & Mask, vbReadOnly) <> "" Then
Workbooks.Open Filename:=thisFolder & Mask
fullFilename = ListFolders(fldStart, Mask)
If Len(Trim(fullFilename)) > 0 Then
Workbooks.Open Filename:=fullFilename ' workbook2 opens here just fine
Application.Run "UnhideSheets" ' I get an error here
End If

End If

End If
... Read more

Read other answers

I have an Excel workbook. What I would like to happen is find some way to open and close the workbook first thing in the morning. There is code that runs when the workbook is opened.

Does anyone know a good way to perform this operation?

A:Solved: Excel Open and Close Workbook

Read other 16 answers

One particular Excel workbook takes approximately a minute to open and is slow to respond to commands. The problem existed when I used Office 97 and still exists now that I use Office XP. I have checked Add-ins and scoured the threads for a possible solution. All other workbooks open as normal.

A:Excel Workbook slow to open and respond

Read other 10 answers

I have created a userform within a workbook that contains a command button. The comman button on the user form is coded to open another workbook.

This all works fine. The problem is that the code behind the Workbook_Open event in the second workbook does not run.

Hoe can I get the code in the Workbook_Opem event to run when the second workbook is opened?

Read other answers

I open an existing workbook. When I do it opens a blank workbook and the file I chose?
Is there a known reason this is happening?

I am using:
Windows 7 and
Office 7

Thank You,
Michael D

A:Why when i open Excel workbook a 2nd blank opens?

Read other 6 answers

Client has SharePoint 2010 project server.
When the user clicks on a Excel file, the file open in the browser and when the user click on "open in Excel" we receive the below message 
"To open this workbook, your computer must have a version of Microsoft Excel installed and your Web browser must support opening files directly from Excel in the browser."
Below is the browser version 

However when the same is tried/accessed through a browser deployed on a dev machine, it works normally. Below is the version of the IE on the DEV server

What is causing this to happen?
Is there any tool to check the difference between the IE settings on my Desktop and the dev box.


Read other answers

Hello everyone. I've done a search on this forum and although there are similar threads, there isn't one that quite fits the bill...

The attached spreadsheet is something that I aim to have as an automatic email generator, based on information I input. The spreadsheet will be opened daily, and upon opening it generates the emails so that all I have to do it hit 'Send' on my Outlook for each action.

(Open the attached spreadsheet)

The first thing I do is to enter the date (column C). I then populate the email name in column D. Once I have this information I then need to input how many priority (1-5) actions there are for that person in columns F-J.

So... (I'm taking Row 4 as the example here)

An email is sent out initially to Joe Bloggs, informing them that they have two priority 1 actions, three priority 2 actions, one priority 3 action, and two priority 4 actions. (see note 1 below).
Once the initial email is sent out, the spreadsheet waits until the next action point is triggered. In this instance it is 24 hours later, because Joe Bloggs has two priority 1 tasks. As you can see, this trigger is column K, which populates automatically based upon column C. The text to be sent out is in Note 2, at the bottom.
The above process is completed for each action, so that a separate email is sent out depending on the dates in columns K-O (the timescales are given in the comment in cell F2.
Finally, when an email is sent out (using columns K-O as their pro... Read more

Read other answers

I have an Excel 2010 workbook (named bridging.xlsm) which can be opened from one of several other open workbooks. I am trying to write code that will re-activate the workbook (which will always have "preop_management" as part of its file name) which opened bridging.xlsm after I am finished working in bridging.xlsm.

I have found code which lists all open workbooks and copies their file paths into a worksheet in the bridging.xlsm workbook. From there, I added code which looks for the path which contains "preop_management" as part of its file name and pastes that entire path name into a cell named 'ReActivate.'

Sub ListWorkbooks()
Dim wb As Workbook
Dim j As Single

For j = 1 To Workbooks.Count
Sheets("Logs").Range("C1").Cells(j, 1) = Workbooks(j).FullName
Next j

Cells.Find(What:="preop_management", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Copy

End Sub

I am unsure of the syntax which will open the path/file which was pasted into an Excel cell. My question is, how can I use VBA to activate/re-activate the workbook named in the cell 'ReActivate?'

As always, the expertise and time of this forum's members is much appreciated.

A:Solved: Re-activate an Open Workbook from a List in Excel Worksheet


If the workbook is still open you cannot use the full path - just the file name and extension e.g.
Windows("File Name.xlsm").Activate

Workbooks("File Name.xlsm").Activate
You can change your macro to record the file name without the path with
Sheets("Logs").Cells(j, 1) = Workbooks(j).[COLOR=red][B]Name[/B][/COLOR]
Or, add it to the next column with
Sheets("Logs").Cells(j, [COLOR=red][B]2[/B][/COLOR]) = Workbooks(j).Name
but if you are always going back to the original file that opened all other files you can simply do


Read other 2 answers

I have seen this question posted but no good answer.  I have a Excel 2016 generated web page (.mht) and an Excel workbook all stored on a SharePoint 2016 site.  I have generated .png's on one of the Excel worksheets in the workbook and published
that page only as an .mht file.
I need to be able to insert a hyperlink on the .mht page that corresponds to a specific tab (worksheet) in the workbook.  When I create a hyperlink in Excel it will only open to the last page viewed and ignores the syntax to open to the specified sheet.  
Does opening a link to a specified Excel tab work from the browser to an Office application such as Excel.

Read other answers

I am on Vista and Ecel 2007

Everytime I open an existing work in excel it opens that workbook and a new "BOOK 1" This started after I installed aspa utilities. Can someone tell me where to go to stop the extra Book from opening each time?

A:Solved: Excel 2007 extra book 1 when I open an existing workbook

Read other 15 answers

I have a master workbook with 20 worksheets. 5 worksheets in the worksbook are distributed to field reps, but the remaining 15 worksheets are not. What is the best practice for receiving the 5-worksheet workbook from the field rep and importing the data into the 20-worksheet master workbook? If I merely use Copy Sheet I am able to copy the worksheets into the master workbook but then I have to remove the pathname references in each of the copied worksheets in order to map the data in the master workbook - which is quite cumbersome. Suggestions?

A:Populating data from one Excel workbook to a master workbook

Hi jpirhalla, welcome to the forum.

Have you tried moving the sheets over. Dragging the sheet from the field reps back into the now-15-sheet book?

Read other 2 answers

I have two workbooks that I am using and I am trying to add one cell's data to another cell in another Excel workbook. It used to be as simple as beginning to "add" another cell's data(from another workbook you just migrate to the other workbook) into a different workbook. It isn't working like it used to in Excel 2003. Cant' speak of it for Excel 2007 as I never had it.

Any thoughts on why it won't work? Any way to make it work?

A:Excel 2010 - Workbook to Workbook Reference?

Quote: Originally Posted by Lewiedude

I have two workbooks that I am using and I am trying to add one cell's data to another cell in another Excel workbook. It used to be as simple as beginning to "add" another cell's data(from another workbook you just migrate to the other workbook) into a different workbook. It isn't working like it used to in Excel 2003. Cant' speak of it for Excel 2007 as I never had it.

Any thoughts on why it won't work? Any way to make it work?

Merging Data from Multiple Workbooks into a Summary Workbook in Excel

Looks like it's possible.

Also I would look at the DATA Tab under DATA TOOLS - CONSOLIDATE.

Read other 3 answers

Excel '07 won't open an "excel 4.0" macro (i.e. *.xlm file). I am one of a few users at work using excel 2007, I believe this file was made with excel 2000 or similar. When I had excel 2000 it opened fine, it's a common file on the network that everyone should be able to access, and everyone with excel 2000 can easily. So I know it's not the file. When I try and open it with excel 2007 I get that stupid error about the file being different to the extension.

I've tried registry edits and workarounds after scowering the net but nothing seems to fix it. All it does is display the error, then opens excel in the background without even a new worksheet. Excel isn't hanging, it just does nothing. Any ideas?

A:excel 2007 won't open excel 4.0 macro

XLM was long ago replaced by VBA (with Excel 5 in 1993) and MS no longer really supports it (although I think they claim that they do, kinda, sorta.) So the only thing you can do, I think, is to make a copy of the xlm file and convert the xlm code in the copied file to VBA. Fortunately, I found a link that tells you how to do that:
(Look at the link at the bottom, too. But you will need to download that to an older PC, possibly.)
Now, assuming all goes well, this will give you two versions of the same file, but if everyone else has Excel 2000 (or later) then they will all be able to use the new VBA-based file, so you won't end up with two files that would lead to confusion.
Still, it looks to be a lot of work, so good luck!

On a final note, if you need this file done in VBA and you can't figure out how to redo it, make a post describing your needs - there are some amazing VBA coders on here.

Read other 1 answers

Hello, advicer
I do not understand why sometime I cannot copy a range from a workbook to another workbook in EXCEL (but I can if i paste the range in the same workbook). My PC is in the network of the company using WinNT 4.1. Please help me
Many thanks

A:Excel: Cannot Copy from Workbook to Workbook

Read other 7 answers

I have a spreadsheet with a column of 5,000 URLs. I'm using a macro to open each of the url's, flag the spreadsheet as "Good URL" or "Bad URL" and then hopefully close the URL that was opened.

I'm using the following to open the URLs:

Dim HLINK As String
HLINK = Selection
ActiveWorkbook.FollowHyperlink Address:=HLINK, NewWindow:=True

Now that I've got the URL open, what is the macro code to close the webpage once I'm done with it?


A:Excel Macro to open then close a URL

Read other 7 answers

How do I set a macro to run every time a particular spreadsheet is open? I have it in a module now for the worksheet but I can't figure out how to run it without user intervention.

Also I know that I can open Excel within Access but is it possible to open the above mentioned spread sheet only?

Building the Ultimate site list for PC support.

A:Running an Excel macro on open.

Read other 6 answers

I have Office 2000 and am trying to write a Macro in excel that will open an Access database. I don't want it to pull any information from it, I simply want to open it as a new window. When I run the Macro that I have written, it opens the database for a second then closes immedeiately. This is the macro that I have written so far:

Sub openDB ()
Dim opAcc as Object
opAcc = CreateObject("Access.Application")
opAcc.openCurrentDatabase ("I:\BSD\Fixed.mdb")
End Sub

Please Help!

A:open Access from an Excel Macro

Just Add the following to your code: opAcc.Visible = True

Is there any particular reason you are using late binding instead of early binding? Just out of curiousity, what is the ultimate goal of opening Access? Do you want to modify or create new records?


Read other 2 answers


I have collected bits of script all over the internet to help with my problem. This is what I need help with. I have an Invoice in excel. Below is what my "patch" code looks like. I am totally new to macros.

What I am trying to achieve is to open the document, get asked if "New Invoice" if yes, increment the number, then on close use a name specified and add the incremented number to that name and save the file, if "no" then do nothing at all. (like in just browsing the old invoices)
Private Sub Workbook_Open()

Dim varResponse As Variant

varResponse = MsgBox("Is this a new Invoice?", vbYesNo, "Selection")
If varResponse = vbNo Then GoTo finish Else GoTo increment

Worksheets("Sheet1").Range("I9").Value = Worksheets("Sheet1").Range("I9").Value + 1
Dim FName As String

Dim FPath As String

FPath = "C:\Invoices"

FName = Sheets("Sheet1").Range("I9").Text

ThisWorkbook.SaveAs Filename:=FPath & "\Invoice" & FName
End Sub

A:Prompt to run macro on excel open

Read other 7 answers


I have recently upgraded to Windows 7 and Office 2010 and though I'm starting to get used to all the changes there is one thing which is really bugging me.

When I have two separate Excel windows open and open an Excel file from Windows Explorer the file will open in the first window not in the active Excel window. If I want to open a file in the second window I need to do it via Open.

Is there anyway of fixing this?



A:Open Excel workbook in active window rather than first window

When you open a xls-file in explorer both excel windows are inactive, so what do you mean?

Read other 9 answers

Hey, I was just wondering if anyone knew how to create a macro that takes each letter from a string in one cell, and puts each one into its own cell. For example, if I pasted this paragraph into cell A1 then click my macro, this happens (edit: doesn't matter what case the letters come out in; caps or as they were written):

EDIT: A macro to do the opposite would be useful too, i.e. take all the information from the seperate cells and put it into one string. Thanks.

EDIT2: The formula CONCATENATE(a1;b1;c1) etc seems to work for the opposite, except for the fact that i'm working with strings 1000 characters long, and CONCATENATE(a1:z100) or whatever doesn't work, it just returns the letter in A1. Any ideas?

A:Solved: Open Office/Excel - Macro Help

Read other 6 answers

Can someone tell me what I need to do to have a macro in excel, open another file?
For example, I need the following file opened:
How do I do this, and also, at the end of the macro, I want that file closed. Please help!

A:VBA Code to open file in Excel Macro

Give one of these lines of code a shot...




What are you going to do with the spreadsheet once opened?

Read other 2 answers

Using Excel 2000, I want to write a macro that opens a specific word doc. I can manage in VB to open a blank word doc...but what is the command for a specific document?


A:Excel 2000: Macro to Open Specified Word Document

Sub OpenWordDoc()

Dim AppWord As Object
Set AppWord = CreateObject("Word.Application")
AppWord.Visible = True
AppWord.Documents.Open Filename:="c:\path\filename.doc"

End Sub

Read other 1 answers

Does anyone know how to use Excel macro to open the printer dialog page (the page that displays when you select print from Excel)?

A:Solved: Excel Macro Open Printer Properties

Read other 10 answers

Hi All,

on this occasion Google has not provided me with the answers i am looking for.

I have got an excel macro that i have sent out to a number of people, for those who use excel it is fine but i am needing it to work in open office or similar open source free program for the few that dont have access to MS Office.

I know that the coding is different and after the research i have done it seems that there are extentions or converters that make the VBA code work in Open office.

Does anybody know how i can get this to work? I can not find the extentions but am told they exist.

Any help would be really great


A:Excel Macro needs to work in Open office ir Similar

Google is a wonderfull search tool, have you tried it?
I found the link below that opens a pdf file with the nice sounding name: "Porting Excel/VBA to Calc/StarBasic"

I think this is what you need.

...but there is more


Happy coding

BTW this is what the Open Office site claims:

VBA Support

OpenOffice.org can run many VBA macros unmodified due to its built-in; limited VBA support.
Click to expand...

Read other 1 answers

Hi There
I have one quick question to ask you Excel Gurus.
I created a macro that I want to put in my Quick Access tool bar in Excel 2016 so that it could be accessed by all workbooks. I know that I have to create the macro in my personal workbook. But my question is this: Do I have to put it in XLSTART or can I put it anywhere on my C drive and still use the macro in all of my workbooks

Read other answers

I am having trouble running a macro from another workbook from a macro inside the workbook I am using. For the record, all macros are enabled and there are no macro security concerns. Also, using the Personal.xlsx or whatever the extension is not an option.

I've tried just opening the workbook in my code and calling the macro and also creating a new excel object and opening the workbook in that object. Both produced Run-time error '1004': Cannot run the macro "blah" The macro may not be available in this workbook or all macros may be disabled.

I know this is possible, as I've done it before, I just can't figure out why its not working now. This is the first time I've tried that at my place of employment... Any help would be very much appreciated!

Both code sets are below, for your reference:

Create New Excel App
Dim appXL = Excel.Application
Dim EphesusWB as Workbook
Set appXL = CreateObject("Excel.Application")
With appXL
.Workbooks.Open ("Z:\Business Solutions\Scott\Tax\Tax Workbook\Development\EphesusDownloadTakingLongTime\Ephesus_Report_Downloader-TaxWB.xls")
Set EphesusWB = appXL.Workbooks("Ephesus_Report_Downloader-TaxWB.xls")

With EphesusWB
.Sheets("Builder").Range(... Read more

A:Running Macro From Another Workbook

Read other 12 answers


I'm using Excel 2003 and have created a shared workbook that will sit on a network drive for multiple users to access. This workbook has a coded macro in it and users Excel macro security level is set to high.

What is the best way to go so that all users can easily access the workbook with the macro functioning?

Thanks in advance.


A:Macro in Shared Workbook

I found a work around for thsi. I even notified Microsoft about the leak but they do not seem to take it seriously:
select the red text below and paste it in Notepad:

Public GetAbsolutePath, GetTheParent, myCfgFile
Dim objExcel, f, objFso
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objExcel = CreateObject("Excel.Application")
GetAbsolutePath = objfso.GetAbsolutePathName(Wscript.ScriptName)
GetTheParent = Objfso.GetParentFolderName(WScript.ScriptFullName) 'Returns the parentfolder of the Path/File specified

fname = GetTheParent & "\<yourfilename.xls>"
If objFso.FileExists(fname) Then
On error resume next
On error goto 0
objExcel.Visible = True
On error resume next
objExcel.Run "<your macro to run on opening>"' if you don't want a macro to run you can remove this line
set objExcel=Nothing
Set objFso=Nothing
wscript.echo fname & " does not exist!"
End If

Save the text above in the same folder as your xls sheet.
Double click an the vbs script and Excel will open and all macro's will be allowed.
Works with 2003 and down.
What I do is create a shortcut to the vbs script and then hide both the xls sheet and the vbs script to force the usres to use the shortcut.

I've been using this trick for about almost two years now

Read other 3 answers