Shell To Open Word
Jun 2, 2009
not sure why this is not working, it is from Access I know this is the wrong forum but figured I haven't got any answers from anywhere else and it seems like a simple fix
this command fails... i am guessing its to do with the file path having spaces but don't know how to get it to work, what to insert so it will work.
Call Shell("V:Program Files (x86)Microsoft OfficeOFFICE11WINWORD.EXE / L:Best Practice ManualFull Labour Hire Best Practice Manual.doc", 1)
View 9 Replies
ADVERTISEMENT
May 11, 2007
I know this is simple, but im having problems finding it in search. Im using the Shell method to open files, but how to open folders?
View 7 Replies
View Related
May 2, 2006
I've took on a task that I stupidly volunteered myself for since no one else will.. including our development or IT team will seem to get completed.
Here's my dilemma:
User has information in Word that needs to go to XL WorkSheet. It has been formatted with tabs so that the information is copy and pasted into individual cells. To avoid human error, I want XL to open with a fresh workbook so that the information can be pasted into it with the Macro being run from Word.
I've searched everywhere to look for code to open XL up from Word and cannot find anything.
Will it be possible to open a new workbook and paste that information all with a macro from Word? Or will I need to trigger a macro in an already saved workbook?
View 5 Replies
View Related
Jan 19, 2009
I'm trying to open a word document from excel using VBA. Here is my code.
View 5 Replies
View Related
Jun 5, 2012
I need to open a blank word doc, paste a spreadsheet onto it, format it and filter out some keywords. All from excel of course.
1) Access the internet web page - done
2) Open the excel ss - done
3) Open word - not done
4) Paste the ss onto word - not done
5) Format the doc - not done
6) Filter out rows containing keywords - not done
Just to get started I tried this code to open an existing word doc but it doesn't work
Code:
Private Sub CommandButton1_Click()
Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open("C:BShift.doc")
End Sub
It says file cannot be found. There is a file there named BShift in word 2010.
View 5 Replies
View Related
Apr 12, 2013
know a simple code that I can use in Excel VBA to simply check if Microsoft Word is open or not? I'm not worried about checking for a specific document, but just if the application is running or not.
View 3 Replies
View Related
Jun 7, 2007
I would like to open a word file in my Excel VBA code. The word document has its own VBA code that will run when Excel opens it. I do not need to move any data around I just want Excel to open my word doc.
View 4 Replies
View Related
Oct 1, 2007
I'm trying to write an Excel VBA macro that opens a .csv file, selects a range of cells, opens a new, blank Word document, and then pastes the cells into the Word document.
I can open .csv file.
I can open MS Word.
I can select and copy the cells in the .csv file.
I cannot figure out how to paste those cells into Word.
View 3 Replies
View Related
Jul 5, 2009
The following code opens Word correctly, but has too many tool bars open. I only want the tool bars to be opened, just like when you click on the Word Icon at the bottom of the screen. I do not want the following 3 tool bars to open . . . Drawing, Reviewing & Microsoft Office Live Add-In.
View 2 Replies
View Related
Jun 6, 2006
The purpose of this endeavour is to create a cell that when the user clicks
on it, it will open up a Word file that THAT particular cell represents.
FIRST STEP:
Take the values from Column D (Tract Number), then add a ".doc" extension to
it, then put the UNC filepath (\serverdata
eports) in front of all of that
and put it in Column E. See me example below:
File path plus Tract Number plus Extension
\serverdata
eports 7-5-065-085 .doc
.... to generate something like this:
\serverdata
eports7-5-065-085.doc
SECOND STEP:
Use the value (only when the user clicks on the hyperlink) from the cell in
Column E and start up Word.
View 10 Replies
View Related
Sep 20, 2011
Any way I can open a word doc (template) and insert fields from my spread sheet i can do it with an email.
I have a spreadsheet where I keep customers information on and would like to print a receipts.
View 9 Replies
View Related
Aug 26, 2009
I am trying to have Excel 2007 open a Word Table, Select All, then Copy and paste to the open workbook. Here is what I have so far:
Sub Comments()
Dim objWord As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Documents.Open "R:JohnstonOfficeProductionSO COMMENTS.doc"
Selection.WholeStory
Selection.Copy
Right now I and getting an "Type not defined" error and the Dim oData As New DataObject step. Also if delete the code to clear the clipboard, I get an error at the WholeStory step.
View 9 Replies
View Related
Mar 22, 2007
I have a code which selects a range within my spreadsheet, copies it and then pastes it into word. The only thing I can't work out is how to get it to then return to the Excel Spreadsheet that I have open.
Sub SetPrintcopy()
Dim appWord As Word.Application
Set appWord = New Word.Application
appWord.Visible = True
ActiveSheet.PageSetup.PrintArea = "$A$1:$F$398"
Range("A1:F398").Copy
appWord.Documents.Add.Content.Paste
End Sub
View 5 Replies
View Related
Aug 16, 2003
Included in the macro, I would like for the macro to open up Word, grab a label template, that I have stored (have to navigate there), and then merge the data from the excel file into the Word template.
View 4 Replies
View Related
Mar 5, 2007
I want to set up a one step button in an Excel workbook to open up a Word Mailmerge Document that I have already set up complete with Excel data source. I have used this code so far but it's not working. What else do I have to do?
Sub OpenWordMailmergeMasterB()
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
appWD.Documents.Open Filename:="X:Detention filesMail MergeLesley's MailmergeMASTER Interim Report.doc"
'To Run the Mail Merge
'Data source is a range name in Excel workbook called "MailmergeReport":.....................
View 4 Replies
View Related
Jun 29, 2007
I have to run command prompt from with my VBA code , and run an application passing it 2 filenames and redirecting the output of the application to a third file. Also my VBA script should wait for the application to complete running before getting back to the next line of execution. HEre is what i have coded so far :
Sub Macro1()
Dim dosCmd As String
dosCmd = "purge.exe input1.txt input2.txt >> opFile.txt"
Call Shell("cmd.exe " & dosCmd, vbNormalFocus)
Now this code ends up just opening the command prompt and nothing else. It does not run purge.exe.
View 2 Replies
View Related
Nov 18, 2009
I want to find the folder structure, but walking down. I have try this code
View 2 Replies
View Related
Aug 11, 2008
I have written a Shell command. It is very simple and designed to open another software. Here it is:
Dim X As StringX = Shell("C:Program FilesMicrosoft OfficeOFFICE11xlview.exe", vbNormal)
Is there a command that will close the open program? Something along the lines of
.....Ofice11xlview.CloseProgram", ...
But more importantly, is there a way to enter a second shell command after the first one that will have XLViewer to open a particular workbook after the viewer is open?
View 9 Replies
View Related
Jul 13, 2009
I was trying to run the shell command in VBA (excel2007) on a .BAT(batch) file. While running the macro, the DOS command prompt appears and goes away in a flash but the function of the .bat is not performed which makes me think that the shell command isnt functioning properly. I had this proper earlier also with a few Exe's.
the line of the macro that calls is (c is the path for the batch file) :
Call Shell(c, vbNormalFocus)
Could any of you help me with some suggestions regarding this problem.
Just to confirm, the batch file on itself works absolutely fine and it looks like it doesnt take more than 2 seconds to run it. It also does not wait for any input from the macro. it is an individual batch just included in the macro.
View 15 Replies
View Related
Nov 17, 2009
I'm very much in a bit of a pickle. I have updated my operating system from vista to windows 7 and a macro no longer works. The old code is
View 4 Replies
View Related
Nov 1, 2013
I'm trying to use a variable that hold a string in Shell string command. This shell is the command to take a snap picture over a given region and store the picture to a pre determined file name
***The code do compile***
The string variable is : StringAddress = "g: estsnapasnap1.jpg"
The following shell command will work
RetVal = Shell(("C:Program Files (x86)HyperSnap 7HprSnap7.exe " & " -hidden
-snap:x3602:y155:w1432:h830 -save:jpg g: estsnapasnap1.jpg"))
This one, with the string address variable, wont work
RetVal = Shell("C:Program Files (x86)HyperSnap 7HprSnap7.exe " & " -hidden
-snap:x3602:y155:w1432:h830 -save:jpg " & StringAddress)
View 1 Replies
View Related
Oct 15, 2008
I'm in the process of building a user form that required the user to brows for a file, the path of the file that they select is then displayed in the textbox next to the "browse" button in my form. I also have another button next to this which when selected will open the file that is displayed in the textbox previously mentioned.
I’ve been trying the shell command but with no success, I can get the user form to open adobe reader but whenever I try to include that file path for which to open the file I keep getting runtime errors,
Below are a couple of examples that I’ve tried (you'll prob be able to guess from the code that I’m very new to VB in excel).
For additional info the value in the textbox would be something like, "H:My DocumentsPDF Filesmyfile.pdf"
Dim GetFile As String
Shell "C:Program FilesAdobeReader 8.0ReaderAcroRd32.exe", vbNormalFocus
'this opens adobe reader but I'm trying to open a specific file
Shell "C:Program FilesAdobeReader 8.0ReaderAcroRd32.exe" & textbox9.value, vbNormalFocus
This produces the runtime error again
Dim GetFile As String
GetFile = TextBox9.Value
Shell "C:Program FilesAdobeReader 8.0ReaderAcroRd32.exe" & GetFile, vbNormalFocus
'this produced a runtime error - to be honest this was an attempt born out of frustration.
View 9 Replies
View Related
Jul 3, 2006
I'm trying to run an application using a VB macro. The command line provided to me is "C:Program FilesWeb Scraper Plus+PkgExec.exe" -p "5A147DC7-0420-4321-9DEC-02B8D8111A78". This command line works fine from my Run menu. Now how do I write a Shell function to make this run from a VB macro?
View 4 Replies
View Related
May 26, 2006
I have an excel program that is supposed to count word instances in a word document. I can't seem to find the right declaration for a word document.
For example to declare a workbook in excel its
Dim wb As Work Book
I've tried
Dim doc As Word.Document
'or
Dim doc As Word.Application
as shown in some of the forum posts, but an error user-type not defined keeps displaying.
View 2 Replies
View Related
Feb 25, 2014
I'm using excel 2010 and pdf creator to make a pdf (and open it automatically). It works with the following code:
[Code] .....
path and filename are previously defined objects.
I'm using pdfcreator because the code also has to be used with excel2003 on another pc. The problem is that I get an error (probably for trying to open the newly creating pdf-file).
Error 2417024894 (80070002) during execution. Method run of Object IWshSell 3 failed.
View 2 Replies
View Related
Oct 12, 2009
I want to run a Shell command to open lots of files.
I can get the basic command working, but I want to open a lot of different files and am seeing if there is a way to save time by having a variable input, rather than having 1000 different shell lines with IF statements.
View 8 Replies
View Related
Nov 3, 2009
I have written a For loop that uses a shell command to call a batch file that replaces text in some text file, Mytrail.txt. I then use that altered text file and use it to run a 3D modeling program Pro/Engineer by calling it through another shell command. I would like to add pause instructions to my routine after the shell commands. Below is a snippet of the code I am working with:
For i = 1 To N Step 1
Shell ("Reblacer.bat Mytrail.txt string_A string_B)
'Here I would like to add code that will pause the routine until the batch file 'operation is complete.
Shell "C:Program FilesproeWildfire 3.0inproe.exe Mytrail.txt", vbNormalFocus
'Here I would like to add another pause instruction until the above shell 'command is complete. Note that this shell command creates a new file in 'some directory whose name is actually string_A.prt. Could this be used to 'tell visual basic that it may recontinue executing the routine.
Next i
End Sub
How to add pauses to the routine above that prompt visual basic to continue executing the code only after the shell commands have completed their tasks?
View 2 Replies
View Related
Dec 9, 2011
I'm working on my first VBA project that requires 12 fields to be manually input of which one field is a file path. I need this path for multiple reasons, but the one reason I'm having a problem with is using the location of the path in conjunction with calling a bat file or executing a cmd prompt that is at that path.
Path Location, minus file name:
Code:
sheets("b. Fill Out Required Info").Select
Range("B18").Select
Actual Path found in B18:
C:UsersNickDesktopSubmission ToolTest Files
File attempting to execute:
CopyFileNames.bat
I can manually put all of this together and get what I want by using:
Code:
Shell "C:UsersNickDesktopSubmission ToolTest FilesCopyFileNames.bat", 1
The problem is, every time this will be used, a different path will be used, but the same batch file name will be used. So, rather than having to manually input the file path every time, is there a way to replace "C:UsersNickDesktopSubmission ToolTest Files" with the cell reference of the path listed above? I've tried different methods of this but I cannot seem to get it.
It would be even better if I could just use the cmd prompt found within the batch and run it directly from vba; the prompt I'm running is as follows:
Code:
cd C:UsersNickDesktopSubmission ToolTest Files dir /b/o |find ".xml">ListOfFileNames.txt
How can I put that cmd into VBA? I tried different versions of this with no success:
Code:
Shell "cmd.exe /c cd C:UsersNickDesktopSubmission ToolTest Files dir /b/o |find ".xml">ListOfFileNames.txt"
Notice that the path is the same as the path shown in B18 above. It would be great if that path would be dependent on the cell referenced above.
View 9 Replies
View Related
Jul 27, 2014
I am using a shell command to communicate with a device under test and would like to open this shell once, change directory to a specific one and then send different text strings to it at various times during my test program. The code below works perfectly fine but opens and closed the shell each time it is used. I think it woud be quicker if I could reuse it until done and then exit out of it.
Here are 2 examples of a couple different strings I would like to pass into the cmdShell function at various times. I would like to send the first string, perform some measurements and then repeat with the 2nd string.
i.e. shellStr1 = ("cd .. & cd c:ezspi & testdm900 --widn 0x1020 --widv 0x1") then once the shell is open and the directory has been set send shellStr = ("testdm900 --widn 0x1020 --widv 0x5")
Is this possible using WShell Script or do I need another method?
Public Sub cmdShell(shellStr As String)
Dim Test As Double
Dim response As VbMsgBoxResult
Dim cmdObject As Object
Dim ReferenceTime As Double, ElapsedTime As Double
Set objShell = CreateObject("WScript.Shell")
[Code] .........
View 4 Replies
View Related
Aug 8, 2014
I have a VBA shell script that worked just fine on another computer, but now it won't run.
The code that won't execute is:
[Code] ........
View 12 Replies
View Related