Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Activate Workbook

I am trying to store all of my macros in one workbook to use whenever I need them. I understand that I need to have that workbook open to run the macro, but am having a problem getting the macro to run on the correct workbook/worksheet.

The specific problem I am having now is during the reformatting/manipulation of a spreadsheet someone generated from Access. While looking at the excel file, I select Macros from the Tools menu and run the macro I want. The program reformats columns (bold, width, center, etc.) with no problem. After that, I want to look in specific cells for values, but I am getting a "Subscript out of range" error.

What can I do to make sure the macro runs of the correct workbook? I have tried to activate the workbook, but with no success. I am getting a "Subscript out of range" error when I insert the following line:

Do Until Worksheets("xxx").Cells(x, 1) = "" (where xxx is the worksheet name)

Why does the reformatting look at the correct location, but when I get to this part it says it can't find the worksheet.

Any help would be appreciated.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Activate A Workbook Based On A Value In A Cell In Another Workbook
I want to activate another active (open) workbook only if its name is the same as what I have recorded in a cell in my workbook. If it does return the same name then it is activated, otherwise a message box displays.


In my Reports workbook on a worksheet name “formula” in cell B33, I have the value “JulyData”. This represents the name of another workbook (i.e. JulyData.xls)

Before a routine is run to import data into Reports.xls I want to verify that the name of the source workbook is actually “JulyData.xls” (as verified to B33 on my “formula” worksheet) and not “AugData.xls”. If it is “JulyData.xls” then I want the procedure to make it the active workbook and start importing data from selected cells. If it is not, then a message box will display.

I know this code doesn’t work:

TW = Worksheets("formula").Range("B33").Value
If Windows.Activate = TW Then Windows.Activate

MsgBox ("Error - Data workbook name does not match." & vbCr & _
"Select correct month for data import."), vbOKOnly, "Data", a, a

I need some help please

Activate A Workbook With A Variable Name
I have a group of workbooks, and I have a macro that opens, updates and closes them dynamically, so I have variables that controls the name of the file. I'm stuck right now trying to add an activate piece of code. I don't know how to add a variable for the name.

The code I'm trying to do looks like this


Thanks for the help!

Activate Workbook Excel VBA
The following procedure works just fine until I get to the line to activate the workbook (This is just before End Sub). Can anyone tell me why this line does not work?


Public Sub prac()
Dim swb As String
swb = Application.GetOpenFilename
workbooks.Open filename:=swb
With Selection.Interior
.ColorIndex = 0
.Pattern = xlGray8
.PatternColorIndex = xlAutomatic
End With
End Sub

End VBA:

Activate Next Workbook If Exists
Tried searching but to no avail. Found a similarish query but no reply was given.

I want to open up to 15 workbooks, then open another one which will gather information from the rest of the workbooks, and closed them after use.

I am using something like:

Option Explicit

Sub importrapids()
Dim cellb, a
On Error GoTo 999
Sheets("Keyed Remortgages").Select
For a = 1 To 15
If Windows(2).Visible Then Windows(2).Activate Else GoTo 1000
cellb = Range("A65536").End(xlUp).Row
ActiveCell.Offset(cellb, 0).Select
Range(Selection, cells(1)).Select
Windows("Remortgage Cross Checker.xls").Activate
ActiveCell.Offset(0, 1).Select
ActiveCell.Offset(cellb, 3).Select
Range(Selection, cells(1)).Select
Windows("Remortgage Cross Checker.xls").Activate
ActiveWorkbook.Close savechanges:=False
ActiveCell.Offset(cellb + 1, -1).Select
Next a
End Sub

but after closing the last one it still wants to activate the next workbook.

How do I detect if there is a second workbook still open for me to switch to.

First workbook will be the master one, workbooks 2 - 16 will be the ones from which I want to gather data from.


Activate Variable Workbook
Hi, in my Excel macro I've assigned a variable to the workbook name. I'm able to open the workbook using the variable name, but later when I call the Activate event for that workbook, I get the old "Subscript out of range" error. Below is my code:

NewRprt = "C:TestTest.xls"
Workbooks.Open FileName:=NewRprt
'more code purposely omitted
Any ideas why I'm getting an error?

Thanks Much

Easy Question- Activate Workbook
This should be a simple one, but i really can't figure out what i've done wrong.

I just want to activate a workbook, already declared as a public variable (new workbook) called ResultsBook.

But when I try, it gives me an ActiveX error- can't create object.

I'm sure it's my syntax, but really can't spot where!

Here's what i've got...

'Invokes the procedure to check relevant column for non-empty 'cells

'Creates new workbook which will be used to send search results 'to.
Set ResultsBook = Workbooks.Add
ResultsBook.Worksheets(1).Columns.ColumnWidth = 50
ResultsBook.Worksheets(1).Rows.RowHeight = 50
ActiveWindow.WindowState = xlMinimized

'Invokes the procedure to add all relevant projects
'by type to the new workbook.

Unload Me
'Somewhere here lies the problem...
ActiveWindow.WindowState = xlMaximized

Looks fine to me... But I've been staring at a screen all day, so that doesn't count for much.

Thanks to all.


Activate Workbook Which Includes Macro
I have userform with several command buttons. Button should add new sheet to the workbook wich includes this userform. Problem is that if I have another workbook open, button adds worksheet in to this workbook because it is activated

First I tryed do this:

Private Sub cmd_Click()

Workbooks("name of the workbook which includes this macro").activate
addsheets ' program to add sheets

End Sub

Then I realized that if user will change workbook name or will save it to another name program will return error

Question is how can I activate workbook which includes macro without calling it name.

Is It Possible To Activate A Workbook Without Its File Name/path?
If I have a workbook open (file name AlphaMaster.xls) and open a second workbook, is there a way to activate the second workbook without using its file name?

The reason I ask is I need to copy data from many data files, whoes names are different, into the AlphaMaster file.

Each data file will be opened separately, a command button will be pressed in AlphaMaster.xls, and I want to copy and paste the data from the data file to AlphaMaster.xls.

Any ideas?

Thanks everyone.

Excel 2000 Run Code Or Activate Userform In Different Workbook
Hi all,

I have a workbook containing information which I need to paste into several other workbooks (not a problem). On each of these workbooks I then want to run sub routines or launch a userform they contain.

I have tried using Code:Call ??? and Code:Application.Run(???)

I have the basic syntax MyProject.MyModule.MySub but can't get it to work. I believe you can't run a private sub but have changed this (is this right?).


1.    Do I need to add any specific reference tools.
2.    Does anyone have any example code using just text eg "VBAProject.Module1.Macro1", a mixture of variables and text eg Variable1 & "Module1.Macro1" and just using variables.
3.    Can you run code contained in a userform eg "Userform1.Stage1_Click".
4    Do I need to (through VBA) reference the specific workbooks somehow.

As always any help given is much appreciated.


Activate, Ye Stubborn Cell! ACTIVATE I SAY!!!
I'm glad to have one of my trademark needlessly complicated issues to present to you all. In my form is a combo box ('EventMenu'), two text boxes ('AskIt' and 'Moofus') and a button. Nice users will enter a string into the 'AskIt' box and my program will find the cell (all I really want is the row) where that string is found. Users also will have entered text into 'Moofus'; and this text will be entered into a cell on whichever row the AskIt string was found. Which cell, you ask; for there are many. Which cell the Moofus string ends up in depends on what the user selected from the EventMenu combo box.

Here is the script for when the button clicks:

Private Sub Findit_Click()
Loogit = Askit.Value
Hepcat = Moofus.Value
Set C = Worksheets(1).Cells.Find(Loogit, LookIn:=xlValues)
Showit.Value = C.Row
If EventMenu.SelText = "ONSITE" Then Cells(C.Row, 13).Activate
If EventMenu.SelText = "STARTUP" Then Cells(C.Row, 14).Activate
If EventMenu.SelText = "LOAD" Then Cells(C.Row, 15).Activate
If EventMenu.SelText = "MKEY" Then Cells(C.Row, 16).Activate
If EventMenu.SelText = "PROD" Then Cells(C.Row, 17).Activate
ActiveCell.Font.Bold = False
ActiveCell.Font.Size = 10
ActiveCell.Value = Hepcat
End Sub

In my dream world, they enter 1234A into AskIt and the program finds 1234A on row 11; the user selected "MKEY" from the Menu and thus the cell at R11C16 is activated and populated with Moofus.Value.

But all that happens instead is that the Moofus.Value ends up in whichever cell was active when I ran the macro.

Wha happened?

Macro To Save Workbook Is Picking Up Previously Opened Workbook Filename Causing An Error.

I have written a macro to save a file in 3 different locations (one being an HTM file as well). I have several schedule files (created by doing File Save As from an original) that this macro will be applied to. I have inserted the macro into each file and created a Macro Menu item which has been mapped to the "This Workbook" macro item that i have written. (End Background, Begin Problem/Question) When I run this macro from one sheet, close that workbook, open a different workbook and run the macro, my macro looks for the previous file name. I am not "quite" sure if the problem is code related or tied to the menu assignment. I have included the code for reference and hope someone may have a better way of doing this.

Sub SaveHTML()

    Dim conNetPath As String
    Dim conHomePath As String
    Dim conBUPath As String
    Dim fName As String
    Dim HTMLFile As String
    conNetPath = "\atlnewsf04Sudhir KeepStuffskeds"
    conBUPath = "c:Schedules"
    conHomePath = ActiveWorkbook.FullName
    fName = ActiveWorkbook.Name
    HTMLFile = Replace(fName, "xls", "htm")

    Application.DisplayAlerts = False

    ActiveWorkbook.SaveAs Filename:= _
        conNetPath & HTMLFile, FileFormat:=xlHtml, _
        ReadOnlyRecommended:=False, CreateBackup:=False

    ActiveWorkbook.SaveAs Filename:= _
        conBUPath & fName, _
        FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False

'MsgBox conHomePath
    ActiveWorkbook.SaveAs Filename:= _
        conHomePath, _
        FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False

    Application.DisplayAlerts = True
End Sub

When you call this macro from the first file, it works fine. If you close that file and open another file with the same macro and try to run it, it looks for the previously opened file.

Not sure where I goofed. I have included two of the spreadsheets to possibly demonstrate.

Scott Medaugh

Opening A Hard Drive Stored Workbook Through A Workbook Embbed In SAP
Hi guys,

I am looking for alternative ways to open a workbook that might work. This code worked outside of SAP but once I put it into the integrated excel workbook, it fails to open the path it is given. I am pretty sure the cause is that it won't go after the file path inside the computer itself, which explains why it works fine when it is on the hard drive but not integrated.

Code: '*** Declare Variables
    Dim xWb As Workbook 'external workbook
    Dim xWks As Worksheet 'external worksheet
    Dim iWb As Workbook 'internal workbook
    Dim iWks As Worksheet 'internal worksheet
    Dim Crit1 As String, Crit2 As String 'PPG/CPG holders
    Dim Rng1 As Range, Rng2 As Range 'Range holders
    Dim Dat1 As String, Dat2 As String 'date range holders
    Dim xECol As Integer, xERow As Integer 'end col/row for ext worksheet
    Dim iECol As Integer, iERow As Integer 'end col/row for int worksheet
    Dim count1 As Integer, count2 As Integer 'Counters
    '**set internal values
    Set iWb = ActiveWorkbook 'Set to Active workbook
    Set iWks = ActiveWorkbook.Sheets("UISheet") 'Set to UISheet in active workbook
    If Range(importpathcell).Value = "" Then
        Exit Sub
    End If
    '**Open external workbook and sheet using importpathcell
    Set xWb = Workbooks.Open(Range(importpathcell).Value) 'Set to path cell ***THIS IS WHAT FAILS***
    Set xWks = xWb.Sheets("Upload") 'Set to "Upload" sheet in xWb

'**Set start/end variables
    xERow = xWks.UsedRange.Rows(xWks.UsedRange.Rows.Count).Row
    iERow = iWks.UsedRange.Rows(xWks.UsedRange.Rows.Count).Row
    xECol = xWks.UsedRange.Columns(xWks.UsedRange.Columns.Count).Column
    iECol = iWks.UsedRange.Columns(xWks.UsedRange.Columns.Count).Column

    count1 = constStartRow
    'Copy over PPGs
    Do While count1 <= iERow
        Crit1 = iWks.Cells(count1, 1).Value
        Set Rng1 = iWks.Cells(count1, 1)
        For count2 = 1 To xERow
            Crit2 = xWks.Cells(count2, 1).Value
            Set Rng2 = xWks.Range(Cells(count2, 1), Cells(count2, xECol))
            If Crit1 <> "" And Crit2 <> "" Then
                If Crit1 = Crit2 Then
                    Dat1 = iWks.Cells(count1, 3).Value
                    Dat2 = xWks.Cells(count2, 3).Value
                    If Dat1 = Dat2 Then
                        Rng1.PasteSpecial (xlPasteValues)
                        GoTo exitPPGFor
                    End If
                End If
            End If
        Next count2
        count1 = count1 + 1

    'count reset
    count1 = constStartRow
    count2 = 1

    'Copy over CPGs
    Do While count1 <= iERow
        Crit1 = iWks.Cells(count1, 2).Value
        Set Rng1 = iWks.Cells(count1, 2)
        For count2 = 1 To xERow
            Crit2 = xWks.Cells(count2, 2).Value
            Set Rng2 = xWks.Range(Cells(count2, 2), Cells(count2, xECol))
            If Crit1 <> "" And Crit2 <> "" Then
                If Crit1 = Crit2 Then
                    Dat1 = iWks.Cells(count1, 3).Value
                    Dat2 = xWks.Cells(count2, 3).Value
                    If Dat1 = Dat2 Then
                        Rng1.PasteSpecial (xlPasteValues)
                        GoTo exitCPGFor
                    End If
                End If
            End If
        Next count2
        count1 = count1 + 1
    xWb.Close savechanges:=False
    Application.Calculation = calc_mode
    Application.ScreenUpdating = update_mode
    Call SubRoutines.WorksheetProtection(iWks, True)
End Sub

I tried inputting a object file as so but it would fail when it gets to setting Rng2. It would get an error "Run-time error '1004': Method 'Range' of object '_Worksheet' failed". However this did manage to open excel in some form according to the processes on my computer using ctrl-alt-del.

    '**Open external workbook and sheet using importpathcell
    Set owExternalFile = CreateObject("Excel.Application")
    Set xWb = owExternalFile.Workbooks.Open(Range(importpathcell).Value) 'Set to path cell
    Set xWks = xWb.Sheets("Upload") 'Set to "Upload" sheet in xWb

This workbook does not need to actually open on the screen. Just to the degree that a .copy and .pastespecial can be used.

Thank you in advanced for any help and sorry in advanced for somewhat lacking comments. Haven't prettied it up yet.

Edited by - rodmanm on 7/19/2007 10:39:20 AM

Macro To Add Column To Workbook - Based On Data From Another Workbook???
I am trying to create a macro to do the following:

I have an excel file, called Warehouse.xls
This has two columns - Column A, which is ProductCode, and Column B which is WarehouseLocation
This file is a list of all my products, and where they are stored in the warehouse.

I then have a second workbook called Orders.xls
this is automatically generated from various vendors.
This has many columns, but the column relevant here is "ProductCode"

What i need to do, is to run a macro, and have it add a column to the end of my Orders.xls workbook, and populate this with the relevant WarehouseLocation (from Warehouse.xls) based on the value of the Orders.xls ProductCode.

Any ideas where i start?
Im familiar with both visual basic, and SQL (im a dba) but i've never done any vba work as such.

any help, or pointers in the right direction would be great!

i've attached the 2 workbooks.
data.xls is the orders file, and warehouse.xls is the "lookup" table... basically warehouse contains a list of product codes and warehouse locations.

what i want to be able to do, is load data.xls, and load the macro, so that it adds a column "warehouse location" and populates that column with data from the warehouse.xls file, based on the SKU from data.xls


Edit by Moderator:
Please post Excel questions, in the Excel forum.

Thank you.

Question On Protecting Workbook And Shared Workbook
Hi Guyz,

i have a few questions to ask..

1) How do i programatically protect and unprotect a range of cells, for
an example range("A1:G65500")..Means that user cant make modification
to these cells...

2) How do i write a program to share/unshare workbook?

if workbook is shared, unshare it..

Creating A New Workbook From An Open Activeworksheet In Another Workbook
I am trying to Create a new workbook from an open activeworksheet in workbook

Has anyone got any example code just to get me started



Entry Cell In Workbook Will Auto Add To Another Workbook
I have 2 files (order confirmation & order summary). When I key-in data in order confirmation, there will add the data into order summary when click the confirm button. I don't know how to write the VBA code. Can you give me some suggestion ???

Sub addto()
Dim L As Long
For L = 1 To Range("A65536").End(xlUp).Row
If Cells(L, 1) = "" Then
Cells(L, 1).Value ='[order confirmation.xls]Order Confirmations (2)'!$AJ$3:$BD$3

End If
Next L
End Sub

How Do I Copy From One Workbook And Paste To Another Workbook
Please can you help I am trying to copy from one workbook and paste to another


Controlling A Workbook With A Macro In A Different Workbook
I have an excel workbook that contains a key -- a set of placeholders in one column with their associated values in the next column -- and I have a macro that will open a word document and find & replace all those placeholders with the correct macro.

I would like to extend this macro so that it will work for another excel document, not just word documents. So far, when I try to modify the code from the original macro, the workbook that I'm working in (the one that contains the key) things that IT is the activeworkbook, not the other one it's just opened, so it ends up just replacing the placeholders in the key.

Does anyone know how to tell it that I want it to use the find/replace macro on the OTHER workbook it's just opened and not itself?


Run A Macro That Exists In A Workbook From Another Workbook
 I'm looking to run a macro/procedure/function that exists in another workbook. Can anyone point me in the right direction?

Copying A Sheet From One Workbook To Another Workbook
Dear Friends,

          I am trying to copy a sheet from one workbook to another workbook with the following command:

    Sheets(job).Copy Before:=Workbooks("book3.xls").Sheets(2)

          where "job" is a variable that contains the name of the file(2329001).(both the workbooks are opened).

          But when I execute the above command, it is poping up the error "Subscript out of range".

          I'm herewith sending the screenshot for your reference and kindly request you to help me out in overcoming this problem.

S. Sivakumar

1 Workbook Copy On 2 Workbook
Hi I have 2 different workbook,
first is "report" and the second is "history"
Every day I create a new report and I have to copy some cells of it
(for example N5 cell and other) in another excel file called "history"
The file "history" on the preview rows contents the cells of the old reports
so every time I update I have to increase of one row.
For this purpose I have written the macro below, but there is something wrong.
I have already searched the site but I have not find similar case to mine
I'll be very grateful if anybody have suggestions to proceed

Sub copyinhistory()

Dim Wkb As Workbook

' disable screen update

Application.ScreenUpdating = False

' open the workbook history

Workbooks.Open Filename:="C:documentilucianoAdR400Hzstoricostorico.xls"

' count the rows on history

Rng = Selection.Rows.Count

' start from first cell

ActiveCell.Offset(0, 0).Select

' start cicle

For i = 1 To Rng

' check the empty row

If ActiveCell.Value = "" Then

' on the empty row of history file copy the cell N5 from the report file

apportino.xls").She ets("Foglio1").Cells(N, 5).Copy Destination:=ActiveCell


' if the row is not empty increase row

ActiveCell.Offset(1, 0).Select

End If

Next i

Application.ScreenUpdating = True

Set Wkb = Nothing

End Sub

Fill A Vba Form With Excel Workbook Data, Updating The Same Workbook W/ Data From The Form
Okay I have a basic to intermediate understanding on using vba and Excel utilities. I need help with the workflow of my application rather than specific procedures.
I've got data on only one worksheet where each record is defined by an account id. Every cell on each record is populating a specific textbox on a form. The form is a basic interface for users, moving from one record to next. So mostly the data will flow from the worksheet to the form with the exception of one field for each record. The user will update that field as needed on the form. There are only 30 records or so on the worksheet. I can't rationalize learning Access and/or some database connection since there are only a few records and few fields.

This is an example of the field headers and one record:
Account Id, Account Name, Total Balance, Past Due Balance, Status
011,ChevyChaseAccount,$1200,$100,Customer sent in check (not posted).

I can think of only one way to update the form with the data and that is piece by piece:
Code:Private Sub UserForm_Initialize()
    With frmDetail
        '.txtAccountName = ActiveSheet.ActiveCell.Offset(0, 2).Value (this gives me an error since I can't use the offset property for the code in forms)
        .txtAccountName = ActiveSheet.Range("B2").Value (since I can't use offset then I have to resort in a specific address)
        .txtAccountId = ActiveSheet.Range("C2").Value (since I can't use offset then I have to resort in a specific address)
        .txtTotalBalance = ActiveSheet.Range("D2").Value (since I can't use offset then I have to resort in a specific address)
    End With
End Sub

I haven't thought of a way to move from one record to another let alone how to update that one field to another.
Let me know if you have any questions,

App Activate

is there a way I can use appactivate then set that applciation to an object.

here is what i thought it would look like.

dim obj as object
set object = appactivate XXX, true

but that won't work

or is the another way to do this if i know the number that goes in the XXX spot?

The application I'm trying to link to is Vantive and I haven't been able to find any information about how to do this kind of thing

I'm creating a form in Word using VBA for various aspects of the form. I have a command button that attaches the form they're working on to an email attachment. If they filled in the form properly, it will attach the document. If they didn't, it will give the user a message box error saying which text box they didn't fill out properly. My problem is that when using the txtText.activate feature to take the user to the text box they didn't fill out properly after they acknowledge the error message, it doesn't scroll up to the location of the text box in the document. In other words, it puts the cursor in the text box that had the error but it doesn't scroll up to that text box. It does however scroll up if you are on a completely different page than the text box when click the email button. But if any of the page containing the text box is shown it doesn't jump up to it.
This form needs to be compatible with both office 2000 and 97. The .activate works perfect in office 97, but it only puts the cursor on the text box in 2000.
Thanks in advance for any advice.

App Activate ??
ok im trying to tell my program to find the window Terra World Online v6.5

so i put this

appactivate(Terra World Online v6.5) and it works with notepad and wordpad etc but wont work with this , but this is the correct window name

is there another command to tell the program to find the window? thanks alot

How To Activate
I am using a input box to ask quantity and saving it for a calculation. But i need to know how, what if the user clicks on cancel, how do I make the program end instead of giving an error message.

temp = msgbox("blah", vbYesNo, "blah2")
if temp = vbYes then
end if

this works with msgboxes but not with inputboxes, is there a solution????

Help, With App Activate
I want to AppActivate the Internet Explorer that is opperating, regardless of what page it is on. Essentially it must AppActivate any app with the title ending with...

"- Microsoft Internet Explorer"

How can I do that?

MDI Activate
hi all,

i have two applications(std exe projets). i set some parameters in one application and the other application is supposed to react depending on the set parameters.

i used mdi_acticate event for this purpose but it does not fire every time the application is activated.

eg: i set the parameter in first and then click on 2nd application on the start bar.


I had a small application. I created one form. I want if my application is continuously minimised for one or two minmized it should be activated after one minute.
can i do this in visual basic. how can i do this one.
I want to remove icons for minimising and maximing the windows in my form.
I want only the close icon in my form .
I tried this using timer control. but when the vb is activated, then only my program is running.
my requirement which ever the application is running, my form shoul be activated
after one minute (if it is minimised).
that program also someone helped me.
i think i have to talk to windows for this requirment.
is it correct.
can any one help me.

can any one help me please
since I need it urgently please help me asap.

Thanking you

Activate Form
hi people...

i'm with a problem here...

ok, let's start...
my app is already showing on the systray, (that's nice), that's ok...
when i "close" the app clicking on the X on the window, it just hides the window, so i can show it again clicking on the SysTray...

if u try to open the EXE again... my "Sub Main" detects that my app is already loaded, and stops the proccess...

that's alright, but, i wanted that when people try to open the EXE again (if the app is already in the systray) it just shows my form (frmMain) again...

understood ? is there anyway to do it ?

i tried this:

Sub Main()
If App.PrevInstance = True Then
Dim lRet As Long

lRet = FindWindow("ThunderFormDC", "My Main Form")
'Here it's ok, it finds the window...
SendMessage lRet, WM_SHOWWINDOW, 0, 0
'But don't show =(

'Now END this proccess and let the other still open...
End If
'If didn´t find any proccess, so load frmMain...
End Sub

How To Activate Animated Gif's
Thank you for at least reading this post, I appreciate it.

My question is how do you make animated gifs 'play'? I have my gif image in an image box, but when the program runs, it doesn't 'play'. How do I make it 'play'?

Activate Slides

I'm new to visual basic (been using it for 1 week), and need some help.
I have an excel spreadsheet with a load of charts in it and would like to copy them to a powerpoint presentation. I have succeeded in copying the first graph onto the first slide but when I try to copy the next one to slide 2 I get this error message:

Shape (unknown member) : Invalid request. To select a shape its view must be active.

How do I activate the second slide?

This is the code I am using to copy and paste the charts:

Set PPSlide = PPPres.Slides.Add(1, ppLayoutText)
ActiveSheet.ChartObjects(1).Chart.CopyPicture _
Appearance:=xlScreen, Format:=xlPicture

PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

Activate Last Insertion
Hi all

Still hoping someone has some ready made cod eto my earlier post, but in the meantime I am trying to get part way there.

After I insert a picture can I make the inserted picture active within the code?

Sub InsertPicture()
End Sub

picture. Select sort of thing

tia kd (newbie)

Activate A Macro
I have a mainframe that everyday exports some records to a text file and leaves this updated text file on a defined folder. This text file isn't tab separated and I need to use a VB application to make this text file tab separated because the program only imports tab separated data.
I thought about making a macro using excel to tab separate the data in the text file but I have to import the informations to my system.
I would like to know if it is possible to make an application using VB to activate the excel macro ? How ?


De-Activate Macro
I'm trying to deactivate a macro in excel/vba before saving - an equivalent of 'SetWarnings False' in Access.

This app is in Office '97


Activate Window
I have an Access Db which is creating a microsoft excel document, formatting the columns & fonts, adding a pivot table, and closing and saving the document. After this is finished, I have Access prompt a message box.

I'm not closing out Excel so Excel is the active window and I have to re-select Access to click OK on the MsgBox.

Can someone tell me how to make the Access Db into the Active Window?




Why the Worksheet_Activate() event doesn't seems to work?! From VB I open a workbook and set a worksheet to Item(1) my first sheet of my xls file. After I put values in cells like that...
objWorkSheet.Cells(43, 1) = LabelNoDoss.Text &amp; NoDossier2.Text
After, objWorkSheet.Activate and objExcel.Visible = True, so it opens my excel sheet1 with a value in A43, but I have code in the VBA in the worksheet_activate() and it doesn't seems to activate EXCEPT if I change to sheet2 and came back with Sheet1, if I do this, it works...but I don't want the user to do this everytime...
I can't put the code in the because I ABSOLUTELY need the value in A43...

Is it clear?

Here is the VB code

objExcel.Workbooks.Open(Replace(vectPref(3), "photos", "rapports") &amp; LabelNoDoss.Text &amp; NoDossier2.Text &amp; ".xls", Editable:=True).RunAutoMacros Which:=xlAutoOpen //Where I open the my nodossier.xls

Set objWorkSheet = objExcel.Worksheets.Item(1) //sheet 1
objWorkSheet.Cells(43, 1) = LabelNoDoss.Text &amp; NoDossier2.Text
objWorkSheet.Cells(43, 2) = objRS.Fields("comp1").Value
objWorkSheet.Cells(43, 3) = objRS.Fields("comp2").Value
objWorkSheet.Cells(43, 4) = objRS.Fields("comp3").Value
objWorkSheet.Cells(43, 5) = objRS.Fields("comp4").Value
objWorkSheet.Cells(44, 1) = objRS.Fields("lot").Value //I need all these values
objWorkSheet.Activate //and I want to activate sheet1 and execute his code worksheet_activate()

objExcel.Application.DisplayAlerts = False
If objRS.Fields("comp4").Value &lt;&gt; "" Then
objExcel.Sheets("Rapport 3 comparables").Delete
objExcel.Sheets("Rapport 4 comparables").Delete
End If

objExcel.Visible = True
objExcel.Application.DisplayAlerts = True


The only thing I want is my worksheet_activate() works without having to change to sheet2 and come back in sheet1.

Getting An Activate Error?
Textbox2 is an embedded control in Sheet3...I'm using it to activate a range (cell) in sheet2... with previous struggles using embedded controls... if I "Select" the object I'm trying to manipulate...(In this case... Sheet2)... no problem...but I don't want to select anything if I don't have too
any help?

Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim rng As Range
Set rng = Workbooks("BlahBlahblah").Worksheets("Sheet2").Range("C20:C521")
If KeyCode = 9 Or KeyCode = 13 Then
With rng
End With
End If
End Sub


How To Activate An Application
i want to activate and send keystrokes to the textbox of an application that runs on a browser from my visual basic form.i can use the URL of the application running on the browser to accomplish this task. like the block code below

Set IE = New InternetExplorer
IE.Visible = True
IE.NAVIGATE "http:www.sometext..."

but instead of using the URL i want to use the title on the browser to activate or access the application.the title is the title displayed on the title bar, like "VBForums - Post New Thread - Microsoft Internet Application"
please anyone to help

How To Activate A Textbox
I have a form with a Rich textbox and 2 checkboxes. The rich textbox is locked because the user isn't allowed to edit the text in it. When I start the form there is a dotted square around my first checkbox. I don't want any dotted squares around them. When i click at the textbox the dotted square is gone. How can I program this in the form_load that there are no dotted squares ? Thanx in advance.

Activate Window - Need Help!

I need a way to switch the active window. How do I do that? (Like, a button to switch the active window from Outlook to Firefox). Specifically, it'd be nice if it went by process (firefox.exe) and not by title (e.g. "Xtreme Visual Basic Talk - Post New Thread"... etc).


How To Activate Window
im building a tool to update my shoutcasts subtitle text (for the winamp video streams)

i used this code for it :

Private Sub Timer1_Timer()

If chkonoff.Value = 1 Then
AppActivate "NSVCAP", False
SendKeys "%F", True
SendKeys "{DOWN}", True
SendKeys "{ENTER}", True
SendKeys "{TAB}", True
SendKeys "LocalTime "
SendKeys Now(), True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys " ", True
SendKeys "%{F4}", True
End If

End Sub

this works fine but i have to set the focus on the NSVCAP window myself.
if i remove the focus my app closes down and i have to restart it again.

can somebody tell me why it doesnt stay focused ?

and of can this be done with sendmessage *i send text to a childwindow*

any help would be great !!!

MouseDown Before Activate
Hi guys,
I discovered a very starnge thing, at least for me, when you have an application with two forms and you want pass from one to an other, click in any part of the disactivated form, the first event you receive is MouseDown and not the form.activate. This for me is catastrofic because a cannot know where I am. I have two istances of the same form. How can I recognize where I am?
Thanks a lot.

Activate A Tooltip
How can I display the tooltip for a knob control to display the value as it changes?

Enter Key To Activate
Hi everyone

I am using VB6 (Professional) Version.

I have created a form with a label on it and a text box. I want to enter text into the text box and when I depressed the Enter Key (also known as the Return Key) the entered text is then placed in the label.

I know I can do this by also creating a command button and coding it



end sub

What I do not know and despite much experimentation I cannot get the same result simply by using the enter key. I would appreciate any help ot being pointed in the right direction.


Bernard in the UK

Activate Event
The Form_Activate event should be triggered when ever a form is made the current window (eg. Click a different window, and then click the first window). Is this correct?

It seems that it will not respond like that for me. The activate event will be triggered only when the window is first opened and I cannot trigger it again.

Any insight would be appreciated.

Load On Activate
Program Freezes During Image Download...

My application uses an image from the internet as soon as it loads, in other words on the first form after the splash screen. My problem is that when you are on a 56k, a slow connection or when the website is under heavy traffic it takes a good few seconds for this image to load. When you click continue on my splash screen and expect the main form to show up, it doesn't come up at all until the image downloads. How can I make this so the form completely loads and then the image will download and display? I'm trying to find something simple such as...

If Form.Loaded Then
End If

I tried moving the code to my splash screen so it could load there, but I end up with the same problem, my splash screen won't show up until it downloads the image. I tried sticking it in the Form_Activate() sub so that the form would be completely visible by the time that code ran, but that doesnt work either...

If you need any other information, please just reply and let me know. This is really annoying... :/ (I would hate to be a 56k user trying to use this program hehe)

Activate Just Before Shutdown?
Doesn anyone know how to make a program run a few commands just before shutdown?

The code i want to run before shutdown will only take like 1 second, does anyone know how i could do this?

BTW, im using VB4 32 bit if it matters, and it only needs to work on windows XP.

Activate Form
I want to show a form on every other apps after 15 mins to attention user. How to do it

Copyright © 2005-08, All rights reserved