Renaming a Word document from text in controls

Access 2003/XP Pro

I'm opening a Word document, typing some text, and trying to rename it using 
text from a combo and a text box on my form. The first two steps work OK, but 
when I try to rename the document, it comes up with a message box "Object 
required ".

        Dim oWord As Object
        Dim oDoc As Object
        
        'Create the Word application object.
        Set oWord = CreateObject("Word.Application")

        'Open the sample document.
        Set oDoc = oWord.Documents.Add("C:\t2hDoc\DocBlank.doc")

        'Add text
        oWord.Selection.TypeText "Start here."

        'Save the new document
        oWord.ActiveDocument.SaveAs Filename:="t2h" & 
Me.Parent!cboDestL.Column(1).Value & Me.Parent!txtHd.Value & ".doc"
       
        oWord.Visible = True

Thanks in advance

Peter

0
Utf
12/20/2009 5:44:01 AM
access.formscoding 7493 articles. 0 followers. Follow

2 Replies
713 Views

Similar Articles

[PageSpeed] 46

Assuming that this is being run from a module of a form being used as a 
subform, try replacing

Me.Parent!cboDestL.Column(1).Value

with

Me!Parent.Form!cboDestL.Column(1)

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Peter Stone" <PeterStone@discussions.microsoft.com> wrote in message 
news:B34C8DE0-996E-498D-8E91-C2B3C2941F46@microsoft.com...
> Access 2003/XP Pro
>
> I'm opening a Word document, typing some text, and trying to rename it 
> using
> text from a combo and a text box on my form. The first two steps work OK, 
> but
> when I try to rename the document, it comes up with a message box "Object
> required ".
>
>        Dim oWord As Object
>        Dim oDoc As Object
>
>        'Create the Word application object.
>        Set oWord = CreateObject("Word.Application")
>
>        'Open the sample document.
>        Set oDoc = oWord.Documents.Add("C:\t2hDoc\DocBlank.doc")
>
>        'Add text
>        oWord.Selection.TypeText "Start here."
>
>        'Save the new document
>        oWord.ActiveDocument.SaveAs Filename:="t2h" &
> Me.Parent!cboDestL.Column(1).Value & Me.Parent!txtHd.Value & ".doc"
>
>        oWord.Visible = True
>
> Thanks in advance
>
> Peter
> 


0
Douglas
12/20/2009 1:16:01 PM
Thank you Doug

Peter
0
Utf
12/20/2009 5:27:01 PM
Reply:

Similar Artilces:

Font set for reading plain text
I've set Courier as the font to read and compose plain text message. However, I don't have idea why my Outlook showed with Arial rather than Courier. The message was from Yahoo account. It seems no difference where messages came from. Can Outlook show plain text message with the font that I set? Thanks, Charles OL2003 SP2 on XP Pro SP2 ...

Text Box Control contains generated hyperlink
Hi. I have a textbox control on a report that contains a generated hyperlink. I output this report to a PDF and when I click the link it only returns the first line of information. This link contains links to documents that reside in a database, so if the link should contain 10 documents, it only returns 8 because that's what fits on the first line of the link. Any ideas of what is happening? Cathy ...

PDFs and Word Documents in Access Report
I'm trying to give the users an option to insert documents or PDFs into the report. I added an oleobject to the report. However, only page one will be displayed. Is there a way around this? I'd like to just store the filename in my table, then load the document into the OLE Object when the report is loaded. Thanks Vayse There is no method available to display more than the first page of the document. You simply cannot combine an Access report with an external document. The only workaround would be to programmatically: Print all/portion of the Access report Print the external...

download Word file into visio 2007
Anyone know how I can import a normal .doc WORD file which has our schools plan into a trial copy of visio 2007. Was going to us Smartdraw but thought as WORD already in use it would be easy to import into another Microsoft programme. Any assistance would be much appreciated. Thanks Alan Speer Since Word is a text tool and Visio is a diagramming tool, what would be the purpose. You might consider just hyperlinking to the word document instead. al "Alan Speer" <Alan Speer@discussions.microsoft.com> wrote in message news:7EA0022B-9B77-4764-AD35-5D342039D2E7@microsoft...

Sheet tab text color
...

Word/Outlook convert content to a table when forwarding msgs
How do I prevent Word/Outlook from converting the content of a forwarded message to a table (actually, a bunch of nested tables) when I forward a message? Outlook/Word doesn't do this. Apparently the original message was already formatted this way. If you are convince that is not the case (look at the HTML source of the received message), then you'll have to provide some configuration details for us to work with and steps to reproduce. Also, does this happen to all messages or just this one? -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsoft Outloo...

Is it possible to have text and currancy in one cell and ...
Is it possible to have text and currancy in one cell and be able to use the numbers in that cell to make an equation with another? The short answer .. No -- Rgds Max xl 97 --- Please respond in thread xdemechanik <at>yahoo<dot>com ---- "thegen" <thegen@discussions.microsoft.com> wrote in message news:1552FF10-9CAA-42AD-B401-B0D229D6A343@microsoft.com... > Is it possible to have text and currancy in one cell and be able to use the > numbers in that cell to make an equation with another? well maybe depending on how the "text & currency" was ar...

CCTV text insertion??
Is there anyone using text insertion from RMS? I need a way to insert text most times this is done off receipt printer or off a com port. The reason i dont like using a receipt funtion is rms dumps all the info at the end of the transaction i would rather have it while the cashier is ringing up that item. I would use it as a pole display but not everything is sent to the pole display. JUst wondering if anyone else was using text insertion on a rms system. thanks for the help Nope right now only way is printer. "Doug Pic-N-Pac" <DougPicNPac@discussions.microsoft.com> w...

How to skip cells with text strings.
What should I add to the code below to cause it to skip a cell tha contains a text string in the cell above it? I need it to only work o numbers in the cell above it. If ActiveCell.Offset(rowoffset:=-1) <> "" Then ActiveCell = ActiveCell.Offset(rowoffset:=-1) + 1 Application.SendKeys ("{Enter}") End If Thanks so much. mikebur -- mikebur ----------------------------------------------------------------------- mikeburg's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2458 View this thread: http://www.excelforum.com/showthread.php?thread...

Excel text to Word text
How can I copy Excel text, then paste it into MS Word without carrying over the grid lines? Any help would be appreciated. Thanks Ed English I don't believe you can copy and paste without the gridlines. However, in Word, select the data and Table>Convert>Table to Text. -- Greeting from the Gulf Coast! http://myweb.cableone.net/twodays "Ed" <ee15803@att.net> wrote in message news:3f7e21e9.53324199@netnews.worldnet.att.net... > How can I copy Excel text, then paste it into MS Word without carrying > over the grid lines? Any help would be appreciated. Thanks &g...

Convert Incoming Plain Text to HTML
Is there a way to have Outlook (2003) automatically convert incoming Plain Text messages to HTML without manually changing the formatting option? Thanks in advance, Jody As far as I know, no. You can go from HTML to Plain Text but not the other way. "J. Owens" wrote: > Is there a way to have Outlook (2003) automatically convert incoming Plain > Text messages to HTML without manually changing the formatting option? ...

Can't paste text to a document because of macros
When I open a document in Word 07, and try to copy text to it it, I get a message that macros are disabled and to go to help for instructions. Instructions say to close the doc. and reopen with macros enabled. BUT it doesn't say HOW to do that. And, why is this happening all of a sudden and everytime I open a doc.? If this happens with all documents in Word, it's probably being caused by poorly designed code in an add-in (or in the Normal template). Did you install something recently? -- Stefan Blom Microsoft Word MVP "leslie7" <leslie7@discus...

windows forms controls
Does a control similar to the the asp.net repeater or datalist exist for winforms? One where I can have a group of controls repeat like in the asp.net repeater. DataGridView doesn't appear to do that. Ralph wrote: > Does a control similar to the the asp.net repeater or datalist exist > for winforms? > One where I can have a group of controls repeat like in the asp.net > repeater. > DataGridView doesn't appear to do that. I don't know much about the ASP.NET controls. But the Windows Forms namespace includes layout controls, such ...

Creating a Publisher 2007 Document in Arabic
Hi, I currently have a business card designed in Publisher 2007. I want to add a reverse side to it and put the same details on the card in Arabic. I'm going to use a Translation Service to translate the text but could someone tell me what configuration changes I need to make in Publisher and/or Windows in order to be able to paste and style the translated text? Thanks Dominic Help, Type Right to Left... The first entry has the requirements. -- Mary Sauer http://msauer.mvps.org/ <dominic.martin@dtrack.com> wrote in message news:5bb99815-f0f8-4aa3-8a76-b18b6...

Creating XML Text
Hello, I need to create some well formed XML text live in memory. What I really want is to use the XmlTextWriter object applied to some location in memory (Stream or something?), because it does a nice job of formatting/identing, etc. But I can't figure out how to instantiate the XmlTextWriter object correctly w/o a filespec. I'm not allowed to directly instantiate a Stream & therefore a StreamWriter for that matter since there's no filespec involved. Can someone show me some code to make this work? TIA, -- John C. Bowman Software Engineer Thermo Electron Scientific I...

My recent documents
Hi, Someone knows how works my recent documents folder in Windows XP? What is the dll system that it use? Today, in my machine the my recent documents folder lists only files *.txt, *.jpg,*.doc, etc.But files with .wav, for example, are not listed in folder. Is there anyway to modify this filter? For display .wav files in folder, too! Thanks a lot in advance "Paulo Eduardo" <PauloEduardo@discussions.microsoft.com> wrote in message news:4C9AF3E8-C212-486A-8763-7F1B62F26D68@microsoft.com... > Hi, > > Someone knows how works my recent documents folder in Windows X...

Unapplied amount (Multicurrency) in "Apply Sales Documents"
1. A sales invoice is posted for USD 1000.00 (functional currency) 2. Payment received for Euro 840.00 (originating currency) = USD 1002.54 3. Apply sales documents has a balance for USD 2.54 in Unapplied Amount. Only "Terms taken" or "Writeoffs" is possible in case of Underpayment (negative amounts are not possible), but no option is available in case of Overpayment (positive exchange difference). Create an option to handle this in the same window without creating a credit memo. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the ...

Why does Outlook display text in yellow? How can i change it?
When pasting text into an e-mail, it appears in pale yellow. Sometimes, parts of meesages from others are also yellow. How can I prevent this? Are you using stationery by any chance? -- Kathleen Orland "Wise Dog" <Wise Dog@discussions.microsoft.com> wrote in message news:2D2FBAF7-2B2B-4C66-AE33-B2CA5A51B821@microsoft.com... > When pasting text into an e-mail, it appears in pale yellow. Sometimes, > parts of meesages from others are also yellow. How can I prevent this? ...

Why won't my document in Publisher print?
I've created a document; but when I try to print it, I get an error message saying it's unable to print and I should press F1, which just takes me to a help screen. How to troubleshoot problems that you may experience when you try to print to a local printer by using Office programs in Windows XP http://support.microsoft.com/kb/870622/en-us Hardware devices not detected or not working (Vista) http://support.microsoft.com/gp/hardware_device_problems -- Mary Sauer http://msauer.mvps.org/ "mmellow" <mmellow@discussions.microsoft.com> wrote in message news:D85E825B...

problem with printing import of word table
Running Vista Ultimate 64-bit; office pro 2007 suite: How do I get rid of the boxes when trying to publishing? I need to import a table created in word 2007. I can get the text box set for margins and size, but I cannot find the command to keep the boxes surrounding each row and column of the table from printing. I apologize in advance for seeming so ignorant, but this is the first time trying this kind of operation. Your help is totally appreciated in advance. Thanks Do you mean the borders? High-light the entire table, Lines, more lines, select the pre-set grid, expand the colo...

counting embedded text #2
If I format the information with "Valid" or "Not Valid" first followe by an explaination, it works. The other option is to separate th status from the explaination. IE: have a separate column called vali and put a yes or no and count those. I only have about 45 entries s far, so it isn't that big of deal. So far, using the wildcard seems to be working -- Shocke ----------------------------------------------------------------------- Shocked's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1489 View this thread: http://www.excelforum.com...

Word's return to previous edit function
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel The 'previous edit' function no longer works. If I'm in a large file, adding something in the middle of it, then save the file and return to it later, the 'go to your previous edit/cursor insertion point' function doesn't work. <br><br>Help!!! Nothing you can do about it: it's a bug introduced in Word 2008, and they're not going to fix it. When you save, Word cleans up the document, and in doing so, Word 2008 is too aggressive and deletes the bookmarks that "Pre...

Word 2007
I have created several tables in a Word document. I would like to know if there is a way to copy the table formatting from one table to the next while still mainiting the information that is currently in the table. Well, one way you could do this would be to:- - click in the Table - TableTools - Design contextual tab - Table Styles group - choose a Style in here and then apply the same Style to the other Tables that you have. If my comments have helped please hit Yes. Thanks. "Sammy" wrote: > I have created several tables in a Word d...

Missing text in email
I am having a problem with Users complaining of email missing the text when it was there originally. Also some have gotten emails back from people saying what they sent was blank, then when they check their sent items... sure enough it is blank!! Running Exchange 2003 on Windows 2003 with latest Service Pac Clients are Outlook 2000 with Latest Patches, etc Changing settings as to how the emails are formatted changes nothing (text/rich text/HTML Any help would be...... helpfull What AV are you running? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion ...

Is it possible to convert a Word graphic into a .jpg file?
I want to insert the graphic into a wiki and need it to be in the .jpg format. I am using Word 7. If not possible, any suggestions? Thank you! You probably mean Word 2007. Try selecting the graphic and copying it (CTRL+C). Open Paint and use Paste (CTRL+V) to paste the graphic into Paint. Now you can save the graphic into any format Paint supports. Yves "GECarter" <GECarter@discussions.microsoft.com> wrote in message news:87055F73-61A8-4D77-9B2A-07C800BAD89C@microsoft.com... >I want to insert the graphic into a wiki and need it to be in the .jpg >...